diff --git a/bsp_hosted/InitMission.cpp b/bsp_hosted/InitMission.cpp index ed6b8820..0ca59db5 100644 --- a/bsp_hosted/InitMission.cpp +++ b/bsp_hosted/InitMission.cpp @@ -1,20 +1,19 @@ #include "InitMission.h" -#include "ObjectFactory.h" #include - +#include #include #include #include -#include #include #include #include - #include #include +#include "ObjectFactory.h" + #ifdef LINUX ServiceInterfaceStream sif::debug("DEBUG"); ServiceInterfaceStream sif::info("INFO"); @@ -27,133 +26,132 @@ ServiceInterfaceStream sif::warning("WARNING", true); ServiceInterfaceStream sif::error("ERROR", true, false, true); #endif -ObjectManagerIF *objectManager = nullptr; +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); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - ReturnValue_t result = tmTcDistributor->addComponent( - objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Object add component failed" << std::endl; - } + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + ReturnValue_t result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - /* UDP bridge */ - PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "TMTC_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Unix Bridge failed" << std::endl; - } - PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Polling failed" << std::endl; - } + /* UDP bridge */ + PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( + "TMTC_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Unix Bridge failed" << std::endl; + } + PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( + "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Polling failed" << std::endl; + } - /* PUS Services */ - PeriodicTaskIF* pusVerification = factory->createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } + /* PUS Services */ + PeriodicTaskIF* pusVerification = factory->createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - PeriodicTaskIF* pusEvents = factory->createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK){ - initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING); - } + PeriodicTaskIF* pusEvents = factory->createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING); + } - PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); - } + PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); + } - PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); - } + PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); + } - PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); - } + PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); + } - PeriodicTaskIF* testTask = factory->createPeriodicTask( - "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + PeriodicTaskIF* testTask = factory->createPeriodicTask( + "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); #if OBSW_ADD_TEST_CODE == 1 - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #endif /* OBSW_ADD_TEST_CODE == 1 */ - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); - tmtcBridgeTask->startTask(); - tmtcPollingTask->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); - pusVerification->startTask(); - pusEvents->startTask(); - pusHighPrio->startTask(); - pusMedPrio->startTask(); - pusLowPrio->startTask(); + pusVerification->startTask(); + pusEvents->startTask(); + pusHighPrio->startTask(); + pusMedPrio->startTask(); + pusLowPrio->startTask(); #if OBSW_ADD_TEST_CODE == 1 - testTask->startTask(); + testTask->startTask(); #endif /* OBSW_ADD_TEST_CODE == 1 */ - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_hosted/InitMission.h b/bsp_hosted/InitMission.h index 01c72008..507de592 100644 --- a/bsp_hosted/InitMission.h +++ b/bsp_hosted/InitMission.h @@ -4,6 +4,6 @@ namespace initmission { void initMission(); void initTasks(); -}; +}; // namespace initmission #endif /* BSP_LINUX_INITMISSION_H_ */ diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 6803ace4..e1be7588 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -1,14 +1,14 @@ #include "ObjectFactory.h" -#include "OBSWConfig.h" + +#include +#include +#include +#include #include #include #include -#include -#include - -#include -#include +#include "OBSWConfig.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTcPollingTask.h" @@ -20,29 +20,28 @@ #include - #if OBSW_ADD_TEST_CODE == 1 #include #endif -void Factory::setStaticFrameworkObjectIds(){ - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; +void Factory::setStaticFrameworkObjectIds() { + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } -void ObjectFactory::produce(void* args){ - Factory::setStaticFrameworkObjectIds(); - ObjectFactory::produceGenericObjects(); +void ObjectFactory::produce(void* args) { + Factory::setStaticFrameworkObjectIds(); + ObjectFactory::produceGenericObjects(); - new TestTask(objects::TEST_TASK); + new TestTask(objects::TEST_TASK); } diff --git a/bsp_hosted/ObjectFactory.h b/bsp_hosted/ObjectFactory.h index feaba70e..b042f9dc 100644 --- a/bsp_hosted/ObjectFactory.h +++ b/bsp_hosted/ObjectFactory.h @@ -1,10 +1,9 @@ #ifndef BSP_LINUX_OBJECTFACTORY_H_ #define BSP_LINUX_OBJECTFACTORY_H_ - namespace ObjectFactory { - void setStatics(); - void produce(void* args); -}; +void setStatics(); +void produce(void* args); +}; // namespace ObjectFactory #endif /* BSP_LINUX_OBJECTFACTORY_H_ */ diff --git a/bsp_hosted/boardconfig/etl_profile.h b/bsp_hosted/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_hosted/boardconfig/etl_profile.h +++ b/bsp_hosted/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_hosted/boardconfig/gcov.h b/bsp_hosted/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_hosted/boardconfig/gcov.h +++ b/bsp_hosted/boardconfig/gcov.h @@ -6,8 +6,9 @@ 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; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_hosted/boardconfig/print.c b/bsp_hosted/boardconfig/print.c index f35f9447..9653fe5f 100644 --- a/bsp_hosted/boardconfig/print.c +++ b/bsp_hosted/boardconfig/print.c @@ -3,13 +3,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_hosted/comIF/ArduinoComIF.cpp b/bsp_hosted/comIF/ArduinoComIF.cpp index 2db293e6..be136e45 100644 --- a/bsp_hosted/comIF/ArduinoComIF.cpp +++ b/bsp_hosted/comIF/ArduinoComIF.cpp @@ -1,376 +1,351 @@ #include "ArduinoComIF.h" -#include "ArduinoCookie.h" -#include #include +#include #include +#include "ArduinoCookie.h" + // This only works on Linux #ifdef LINUX -#include #include +#include #include #elif WIN32 -#include #include +#include #endif #include -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); + initialized = false; + serialPort = ::open("/dev/ttyUSB0", O_RDWR); - if (serialPort < 0) { - //configuration error - printf("Error %i from open: %s\n", errno, strerror(errno)); - return; - } + if (serialPort < 0) { + // configuration error + printf("Error %i from open: %s\n", errno, strerror(errno)); + return; + } - struct termios tty; - memset(&tty, 0, sizeof tty); + struct termios tty; + memset(&tty, 0, sizeof tty); - // Read in existing settings, and handle any error - if (tcgetattr(serialPort, &tty) != 0) { - printf("Error %i from tcgetattr: %s\n", errno, strerror(errno)); - return; - } + // Read in existing settings, and handle any error + if (tcgetattr(serialPort, &tty) != 0) { + printf("Error %i from tcgetattr: %s\n", errno, strerror(errno)); + return; + } - tty.c_cflag &= ~PARENB; // Clear parity bit, disabling parity - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_lflag &= ~ICANON; //Disable Canonical Mode - 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 - tty.c_cc[VTIME] = 0; // Non Blocking - tty.c_cc[VMIN] = 0; + tty.c_cflag &= ~PARENB; // Clear parity bit, disabling parity + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_lflag &= ~ICANON; // Disable Canonical Mode + 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 + tty.c_cc[VTIME] = 0; // Non Blocking + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); //Baudrate + cfsetispeed(&tty, B9600); // Baudrate - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - //printf("Error %i from tcsetattr: %s\n", errno, strerror(errno)); - return; - } + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + // printf("Error %i from tcsetattr: %s\n", errno, strerror(errno)); + return; + } - initialized = true; + initialized = true; #elif WIN32 - DCB serialParams = { 0 }; + DCB serialParams = {0}; - // we need to ask the COM port from the user. - if(promptComIF) { - sif::info << "Please enter the COM port (c to cancel): " << std::flush; - std::string comPort; - while(hCom == INVALID_HANDLE_VALUE) { + // we need to ask the COM port from the user. + if (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; + } + const TCHAR *pcCommPort = comPort.c_str(); + hCom = CreateFileA(pcCommPort, // port name + GENERIC_READ | GENERIC_WRITE, // Read/Write + 0, // No Sharing + NULL, // No Security + OPEN_EXISTING, // Open existing port only + 0, // Non Overlapped I/O + NULL); // Null for Comm Devices - std::getline(std::cin, comPort); - if(comPort[0] == 'c') { - break; - } - const TCHAR *pcCommPort = comPort.c_str(); - hCom = CreateFileA(pcCommPort, //port name - GENERIC_READ | GENERIC_WRITE, //Read/Write - 0, // No Sharing - NULL, // No Security - OPEN_EXISTING,// Open existing port only - 0, // Non Overlapped I/O - NULL); // Null for Comm Devices + if (hCom == INVALID_HANDLE_VALUE) { + if (GetLastError() == 2) { + sif::error << "COM Port does not found!" << std::endl; + } else { + TCHAR err[128]; + 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::error << err << std::flush; + } + sif::info << "Please enter a valid COM port: " << std::flush; + } + } + } - if (hCom == INVALID_HANDLE_VALUE) - { - if(GetLastError() == 2) { - sif::error << "COM Port does not found!" << std::endl; - } - else { - TCHAR err[128]; - 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::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 { + serialParams.BaudRate = baudRate; + } - } + serialParams.ByteSize = 8; + serialParams.Parity = NOPARITY; + serialParams.StopBits = ONESTOPBIT; + SetCommState(hCom, &serialParams); - - serialParams.DCBlength = sizeof(serialParams); - if(baudRate == 9600) { - serialParams.BaudRate = CBR_9600; - } - if(baudRate == 115200) { - serialParams.BaudRate = CBR_115200; - } - else { - serialParams.BaudRate = baudRate; - } - - serialParams.ByteSize = 8; - serialParams.Parity = NOPARITY; - serialParams.StopBits = ONESTOPBIT; - SetCommState(hCom, &serialParams); - - COMMTIMEOUTS timeout = { 0 }; - // This will set the read operation to be blocking until data is received - // and then read continuously until there is a gap of one millisecond. - timeout.ReadIntervalTimeout = 1; - timeout.ReadTotalTimeoutConstant = 0; - timeout.ReadTotalTimeoutMultiplier = 0; - timeout.WriteTotalTimeoutConstant = 0; - timeout.WriteTotalTimeoutMultiplier = 0; - SetCommTimeouts(hCom, &timeout); - // Serial port should now be read for operations. + COMMTIMEOUTS timeout = {0}; + // This will set the read operation to be blocking until data is received + // and then read continuously until there is a gap of one millisecond. + timeout.ReadIntervalTimeout = 1; + timeout.ReadTotalTimeoutConstant = 0; + timeout.ReadTotalTimeoutMultiplier = 0; + timeout.WriteTotalTimeoutConstant = 0; + timeout.WriteTotalTimeoutMultiplier = 0; + SetCommTimeouts(hCom, &timeout); + // Serial port should now be read for operations. #endif } ArduinoComIF::~ArduinoComIF() { #ifdef LINUX - ::close(serialPort); + ::close(serialPort); #elif WIN32 - CloseHandle(hCom); + CloseHandle(hCom); #endif } -ReturnValue_t ArduinoComIF::initializeInterface(CookieIF * cookie) { - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t ArduinoComIF::initializeInterface(CookieIF *cookie) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, - size_t len) { - ArduinoCookie *arduinoCookie = dynamic_cast(cookie); - if (arduinoCookie == nullptr) { - return INVALID_COOKIE_TYPE; - } +ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie, const uint8_t *data, size_t len) { + ArduinoCookie *arduinoCookie = dynamic_cast(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) { - return RETURN_OK; +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) { + handleSerialPortRx(); + + ArduinoCookie *arduinoCookie = dynamic_cast(cookie); + if (arduinoCookie == nullptr) { + return INVALID_COOKIE_TYPE; + } + + *buffer = arduinoCookie->replyBuffer.data(); + *size = arduinoCookie->receivedDataLen; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, - uint8_t **buffer, size_t *size) { +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; + } - handleSerialPortRx(); + // being conservative here + uint8_t sendBuffer[(dataLen + 6) * 2 + 2]; - ArduinoCookie *arduinoCookie = dynamic_cast(cookie); - if (arduinoCookie == nullptr) { - return INVALID_COOKIE_TYPE; - } + sendBuffer[0] = DleEncoder::STX_CHAR; - *buffer = arduinoCookie->replyBuffer.data(); - *size = arduinoCookie->receivedDataLen; - return HasReturnvaluesIF::RETURN_OK; -} + uint8_t *currentPosition = sendBuffer + 1; + size_t remainingLen = sizeof(sendBuffer) - 1; + size_t encodedLen = 0; -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; - } + 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 - //being conservative here - uint8_t sendBuffer[(dataLen + 6) * 2 + 2]; + result = DleEncoder::encode(&address, 1, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - sendBuffer[0] = DleEncoder::STX_CHAR; + uint8_t temporaryBuffer[2]; - uint8_t *currentPosition = sendBuffer + 1; - size_t remainingLen = sizeof(sendBuffer) - 1; - size_t encodedLen = 0; + // note to Lukas: yes we _could_ use Serialize here, but for 16 bit it is a bit too much... + temporaryBuffer[0] = dataLen >> 8; // we checked dataLen above + temporaryBuffer[1] = dataLen; - 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(temporaryBuffer, 2, 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); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + // encoding the actual data + result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - uint8_t temporaryBuffer[2]; + uint16_t crc = CRC::crc16ccitt(&command, 1); + crc = CRC::crc16ccitt(&address, 1, crc); + // fortunately the length is still there + crc = CRC::crc16ccitt(temporaryBuffer, 2, crc); + crc = CRC::crc16ccitt(data, dataLen, crc); - //note to Lukas: yes we _could_ use Serialize here, but for 16 bit it is a bit too much... - temporaryBuffer[0] = dataLen >> 8; //we checked dataLen above - temporaryBuffer[1] = dataLen; + temporaryBuffer[0] = crc >> 8; + temporaryBuffer[1] = crc; - result = DleEncoder::encode(temporaryBuffer, 2, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + result = + DleEncoder::encode(temporaryBuffer, 2, currentPosition, remainingLen, &encodedLen, false); + if (result != RETURN_OK) { + return result; + } + currentPosition += encodedLen; + remainingLen -= encodedLen; // DleEncoder will never return encodedLen > remainingLen - //encoding the actual data - result = DleEncoder::encode(data, dataLen, currentPosition, remainingLen, - &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen + if (remainingLen > 0) { + *currentPosition = DleEncoder::ETX_CHAR; + } + remainingLen -= 1; - uint16_t crc = CRC::crc16ccitt(&command, 1); - crc = CRC::crc16ccitt(&address, 1, crc); - //fortunately the length is still there - crc = CRC::crc16ccitt(temporaryBuffer, 2, crc); - crc = CRC::crc16ccitt(data, dataLen, crc); - - temporaryBuffer[0] = crc >> 8; - temporaryBuffer[1] = crc; - - result = DleEncoder::encode(temporaryBuffer, 2, currentPosition, - remainingLen, &encodedLen, false); - if (result != RETURN_OK) { - return result; - } - currentPosition += encodedLen; - remainingLen -= encodedLen; //DleEncoder will never return encodedLen > remainingLen - - if (remainingLen > 0) { - *currentPosition = DleEncoder::ETX_CHAR; - } - remainingLen -= 1; - - encodedLen = sizeof(sendBuffer) - remainingLen; + encodedLen = sizeof(sendBuffer) - remainingLen; #ifdef LINUX - ssize_t writtenlen = ::write(serialPort, sendBuffer, encodedLen); - if (writtenlen < 0) { - //we could try to find out what happened... - return RETURN_FAILED; - } - if (writtenlen != encodedLen) { - //the OS failed us, we do not try to block until everything is written, as - //we can not block the whole system here - return RETURN_FAILED; - } - return RETURN_OK; + ssize_t writtenlen = ::write(serialPort, sendBuffer, encodedLen); + if (writtenlen < 0) { + // we could try to find out what happened... + return RETURN_FAILED; + } + if (writtenlen != encodedLen) { + // the OS failed us, we do not try to block until everything is written, as + // we can not block the whole system here + return RETURN_FAILED; + } + return RETURN_OK; #elif WIN32 - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; #endif } void ArduinoComIF::handleSerialPortRx() { #ifdef LINUX - uint32_t availableSpace = rxBuffer.availableWriteSpace(); + uint32_t availableSpace = rxBuffer.availableWriteSpace(); - uint8_t dataFromSerial[availableSpace]; + uint8_t dataFromSerial[availableSpace]; - ssize_t bytesRead = read(serialPort, dataFromSerial, - sizeof(dataFromSerial)); + ssize_t bytesRead = read(serialPort, dataFromSerial, sizeof(dataFromSerial)); - if (bytesRead < 0) { - return; - } + if (bytesRead < 0) { + return; + } - rxBuffer.writeData(dataFromSerial, bytesRead); + rxBuffer.writeData(dataFromSerial, bytesRead); - uint8_t dataReceivedSoFar[rxBuffer.getMaxSize()]; + uint8_t dataReceivedSoFar[rxBuffer.getMaxSize()]; - uint32_t dataLenReceivedSoFar = 0; + 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)) { - firstSTXinRawData++; - } + // look for STX + size_t firstSTXinRawData = 0; + while ((firstSTXinRawData < dataLenReceivedSoFar) && + (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) { + firstSTXinRawData++; + } - if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR) { - //there is no STX in our data, throw it away... - rxBuffer.deleteData(dataLenReceivedSoFar); - return; - } + if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR) { + // there is no STX in our data, throw it away... + rxBuffer.deleteData(dataLenReceivedSoFar); + return; + } - uint8_t packet[MAX_PACKET_SIZE]; - size_t packetLen = 0; + uint8_t packet[MAX_PACKET_SIZE]; + size_t packetLen = 0; - size_t readSize = 0; + 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) { - handlePacket(packet, packetLen); + size_t toDelete = firstSTXinRawData; + if (result == HasReturnvaluesIF::RETURN_OK) { + handlePacket(packet, packetLen); - // after handling the packet, we can delete it from the raw stream, - // it has been copied to packet - toDelete += readSize; - } + // after handling the packet, we can delete it from the raw stream, + // it has been copied to packet + toDelete += readSize; + } - //remove Data which was processed - rxBuffer.deleteData(toDelete); + // remove Data which was processed + rxBuffer.deleteData(toDelete); #elif WIN32 #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); - if (crc != 0) { - //CRC error - return; - } + uint16_t crc = CRC::crc16ccitt(packet, packetLen); + if (crc != 0) { + // CRC error + return; + } - uint8_t command = packet[0]; - uint8_t address = packet[1]; + uint8_t command = packet[0]; + uint8_t address = packet[1]; - uint16_t size = (packet[2] << 8) + packet[3]; + uint16_t size = (packet[2] << 8) + packet[3]; - if (size != packetLen - 6) { - //Invalid Length - return; - } + if (size != packetLen - 6) { + // Invalid Length + return; + } - switch (command) { - case ArduinoCookie::SPI: { - //ArduinoCookie **itsComplicated; - auto findIter = spiMap.find(address); - if (findIter == spiMap.end()) { - //we do no know this address - return; - } - ArduinoCookie& cookie = findIter->second; - if (packetLen > cookie.maxReplySize + 6) { - packetLen = cookie.maxReplySize + 6; - } - std::memcpy(cookie.replyBuffer.data(), packet + 4, packetLen - 6); - cookie.receivedDataLen = packetLen - 6; - } - break; - default: - return; - } + switch (command) { + case ArduinoCookie::SPI: { + // ArduinoCookie **itsComplicated; + auto findIter = spiMap.find(address); + if (findIter == spiMap.end()) { + // we do no know this address + return; + } + ArduinoCookie &cookie = findIter->second; + if (packetLen > cookie.maxReplySize + 6) { + packetLen = cookie.maxReplySize + 6; + } + std::memcpy(cookie.replyBuffer.data(), packet + 4, packetLen - 6); + cookie.receivedDataLen = packetLen - 6; + } break; + default: + return; + } } diff --git a/bsp_hosted/comIF/ArduinoComIF.h b/bsp_hosted/comIF/ArduinoComIF.h index 84bd959d..8476b6b5 100644 --- a/bsp_hosted/comIF/ArduinoComIF.h +++ b/bsp_hosted/comIF/ArduinoComIF.h @@ -4,8 +4,8 @@ #include #include #include -#include #include +#include #include #include @@ -14,56 +14,53 @@ #include #endif -//Forward declaration, so users don't peek +// Forward declaration, so users don't peek class ArduinoCookie; -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; +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; - static const uint8_t COMMAND_INVALID = -1; - static const uint8_t COMMAND_SPI = 1; + static const uint8_t COMMAND_INVALID = -1; + static const uint8_t COMMAND_SPI = 1; - ArduinoComIF(object_id_t setObjectId, bool promptComIF = false, - const char *serialDevice = nullptr); - void setBaudrate(uint32_t baudRate); + ArduinoComIF(object_id_t setObjectId, bool promptComIF = false, + const char *serialDevice = nullptr); + void setBaudrate(uint32_t baudRate); - virtual ~ArduinoComIF(); + virtual ~ArduinoComIF(); - /** 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 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; + /** 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 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; -private: + private: #ifdef LINUX #elif WIN32 - HANDLE hCom = INVALID_HANDLE_VALUE; + HANDLE hCom = INVALID_HANDLE_VALUE; #endif - // remembering if the initialization in the ctor worked - // if not, all calls are disabled - bool initialized = false; - int serialPort = 0; - // Default baud rate is 9600 for now. - uint32_t baudRate = 9600; + // remembering if the initialization in the ctor worked + // if not, all calls are disabled + bool initialized = false; + int serialPort = 0; + // Default baud rate is 9600 for now. + uint32_t baudRate = 9600; - //used to know where to put the data if a reply is received - std::map spiMap; + // used to know where to put the data if a reply is received + std::map spiMap; - SimpleRingBuffer rxBuffer; + SimpleRingBuffer rxBuffer; - ReturnValue_t sendMessage(uint8_t command, uint8_t address, - const uint8_t *data, size_t dataLen); - void handleSerialPortRx(); + 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); + void handlePacket(uint8_t *packet, size_t packetLen); }; #endif /* MISSION_ARDUINOCOMMINTERFACE_H_ */ diff --git a/bsp_hosted/comIF/ArduinoCookie.cpp b/bsp_hosted/comIF/ArduinoCookie.cpp index bc698720..89cb1568 100644 --- a/bsp_hosted/comIF/ArduinoCookie.cpp +++ b/bsp_hosted/comIF/ArduinoCookie.cpp @@ -1,8 +1,8 @@ #include -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) {} diff --git a/bsp_hosted/comIF/ArduinoCookie.h b/bsp_hosted/comIF/ArduinoCookie.h index a5f91f64..04d4bd83 100644 --- a/bsp_hosted/comIF/ArduinoCookie.h +++ b/bsp_hosted/comIF/ArduinoCookie.h @@ -2,26 +2,21 @@ #define MISSION_ARDUINO_ARDUINOCOOKIE_H_ #include + #include -class ArduinoCookie: public CookieIF { -public: - enum Protocol_t: uint8_t { - INVALID, - SPI, - I2C - }; +class ArduinoCookie : public CookieIF { + public: + enum Protocol_t : uint8_t { INVALID, SPI, I2C }; - ArduinoCookie(Protocol_t protocol, uint8_t address, - const size_t maxReplySize); - - Protocol_t protocol; - uint8_t command; - uint8_t address; - std::vector replyBuffer; - size_t receivedDataLen = 0; - size_t maxReplySize; + ArduinoCookie(Protocol_t protocol, uint8_t address, const size_t maxReplySize); + Protocol_t protocol; + uint8_t command; + uint8_t address; + std::vector replyBuffer; + size_t receivedDataLen = 0; + size_t maxReplySize; }; #endif /* MISSION_ARDUINO_ARDUINOCOOKIE_H_ */ diff --git a/bsp_hosted/fsfwconfig/devices/gpioIds.h b/bsp_hosted/fsfwconfig/devices/gpioIds.h index a4b4ac81..1ede0571 100644 --- a/bsp_hosted/fsfwconfig/devices/gpioIds.h +++ b/bsp_hosted/fsfwconfig/devices/gpioIds.h @@ -2,56 +2,53 @@ #define FSFWCONFIG_DEVICES_GPIOIDS_H_ namespace gpioIds { - enum gpioId_t { - HEATER_0, - HEATER_1, - HEATER_2, - HEATER_3, - HEATER_4, - HEATER_5, - HEATER_6, - HEATER_7, - DEPLSA1, - DEPLSA2, +enum gpioId_t { + HEATER_0, + HEATER_1, + HEATER_2, + HEATER_3, + HEATER_4, + HEATER_5, + HEATER_6, + HEATER_7, + DEPLSA1, + DEPLSA2, - MGM_0_LIS3_CS, - MGM_1_RM3100_CS, - GYRO_0_ADIS_CS, - GYRO_1_L3G_CS, - GYRO_2_L3G_CS, - MGM_2_LIS3_CS, - MGM_3_RM3100_CS, + MGM_0_LIS3_CS, + MGM_1_RM3100_CS, + GYRO_0_ADIS_CS, + GYRO_1_L3G_CS, + GYRO_2_L3G_CS, + MGM_2_LIS3_CS, + MGM_3_RM3100_CS, - TEST_ID_0, - TEST_ID_1, + TEST_ID_0, + TEST_ID_1, - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, - SPI_MUX_BIT_1, - SPI_MUX_BIT_2, - SPI_MUX_BIT_3, - SPI_MUX_BIT_4, - SPI_MUX_BIT_5, - SPI_MUX_BIT_6 - }; + SPI_MUX_BIT_1, + SPI_MUX_BIT_2, + SPI_MUX_BIT_3, + SPI_MUX_BIT_4, + SPI_MUX_BIT_5, + SPI_MUX_BIT_6 +}; } - - - #endif /* FSFWCONFIG_DEVICES_GPIOIDS_H_ */ diff --git a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h index c216c828..ae259374 100644 --- a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h +++ b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h @@ -4,55 +4,54 @@ #include namespace pcduSwitches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum SwitcherList { - Q7S, - PAYLOAD_PCDU_CH1, - RW, - TCS_BOARD_8V_HEATER_IN, - SUS_REDUNDANT, - DEPLOYMENT_MECHANISM, - PAYLOAD_PCDU_CH6, - ACS_BOARD_SIDE_B, - PAYLOAD_CAMERA, - TCS_BOARD_3V3, - SYRLINKS, - STAR_TRACKER, - MGT, - SUS_NOMINAL, - SOLAR_CELL_EXP, - PLOC, - ACS_BOARD_SIDE_A, - NUMBER_OF_SWITCHES - }; +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum SwitcherList { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES +}; - static const uint8_t ON = 1; - static const uint8_t OFF = 0; +static const uint8_t ON = 1; +static const uint8_t OFF = 0; - /* Output states after reboot of the PDUs */ - static const uint8_t INIT_STATE_Q7S = ON; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; - static const uint8_t INIT_STATE_RW = OFF; +/* Output states after reboot of the PDUs */ +static const uint8_t INIT_STATE_Q7S = ON; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; +static const uint8_t INIT_STATE_RW = OFF; #if BOARD_TE0720 == 1 - /* Because the TE0720 is not connected to the PCDU, this switch is always on */ - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +/* Because the TE0720 is not connected to the PCDU, this switch is always on */ +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; #else - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; #endif - static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; - static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; - static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; - static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; - static const uint8_t INIT_STATE_SYRLINKS = OFF; - static const uint8_t INIT_STATE_STAR_TRACKER = OFF; - static const uint8_t INIT_STATE_MGT = OFF; - static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; - 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; -} - +static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; +static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; +static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; +static const uint8_t INIT_STATE_SYRLINKS = OFF; +static const uint8_t INIT_STATE_STAR_TRACKER = OFF; +static const uint8_t INIT_STATE_MGT = OFF; +static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; +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_ */ diff --git a/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h b/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h index 7335a804..9dc50c50 100644 --- a/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h +++ b/bsp_hosted/fsfwconfig/events/subsystemIdRanges.h @@ -2,6 +2,7 @@ #define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #include + #include /** @@ -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_ */ diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index 7b9ce4b5..fb9e1bf4 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -89,176 +89,176 @@ const char *ACK_FAILURE_STRING = "ACK_FAILURE"; const char *EXE_FAILURE_STRING = "EXE_FAILURE"; const char *CRC_FAILURE_EVENT_STRING = "CRC_FAILURE_EVENT"; -const char * translateEvents(Event event) { - switch( (event & 0xffff) ) { - case(2200): - return STORE_SEND_WRITE_FAILED_STRING; - case(2201): - return STORE_WRITE_FAILED_STRING; - case(2202): - return STORE_SEND_READ_FAILED_STRING; - case(2203): - return STORE_READ_FAILED_STRING; - case(2204): - return UNEXPECTED_MSG_STRING; - case(2205): - return STORING_FAILED_STRING; - case(2206): - return TM_DUMP_FAILED_STRING; - case(2207): - return STORE_INIT_FAILED_STRING; - case(2208): - return STORE_INIT_EMPTY_STRING; - case(2209): - return STORE_CONTENT_CORRUPTED_STRING; - case(2210): - return STORE_INITIALIZE_STRING; - case(2211): - return INIT_DONE_STRING; - case(2212): - return DUMP_FINISHED_STRING; - case(2213): - return DELETION_FINISHED_STRING; - case(2214): - return DELETION_FAILED_STRING; - case(2215): - return AUTO_CATALOGS_SENDING_FAILED_STRING; - case(2600): - return GET_DATA_FAILED_STRING; - case(2601): - return STORE_DATA_FAILED_STRING; - case(2800): - return DEVICE_BUILDING_COMMAND_FAILED_STRING; - case(2801): - return DEVICE_SENDING_COMMAND_FAILED_STRING; - case(2802): - return DEVICE_REQUESTING_REPLY_FAILED_STRING; - case(2803): - return DEVICE_READING_REPLY_FAILED_STRING; - case(2804): - return DEVICE_INTERPRETING_REPLY_FAILED_STRING; - case(2805): - return DEVICE_MISSED_REPLY_STRING; - case(2806): - return DEVICE_UNKNOWN_REPLY_STRING; - case(2807): - return DEVICE_UNREQUESTED_REPLY_STRING; - case(2808): - return INVALID_DEVICE_COMMAND_STRING; - case(2809): - return MONITORING_LIMIT_EXCEEDED_STRING; - case(2810): - return MONITORING_AMBIGUOUS_STRING; - case(4201): - return FUSE_CURRENT_HIGH_STRING; - case(4202): - return FUSE_WENT_OFF_STRING; - case(4204): - return POWER_ABOVE_HIGH_LIMIT_STRING; - case(4205): - return POWER_BELOW_LOW_LIMIT_STRING; - case(4300): - return SWITCH_WENT_OFF_STRING; - case(5000): - return HEATER_ON_STRING; - case(5001): - return HEATER_OFF_STRING; - case(5002): - return HEATER_TIMEOUT_STRING; - case(5003): - return HEATER_STAYED_ON_STRING; - case(5004): - return HEATER_STAYED_OFF_STRING; - case(5200): - return TEMP_SENSOR_HIGH_STRING; - case(5201): - return TEMP_SENSOR_LOW_STRING; - case(5202): - return TEMP_SENSOR_GRADIENT_STRING; - case(5901): - return COMPONENT_TEMP_LOW_STRING; - case(5902): - return COMPONENT_TEMP_HIGH_STRING; - case(5903): - return COMPONENT_TEMP_OOL_LOW_STRING; - case(5904): - return COMPONENT_TEMP_OOL_HIGH_STRING; - case(5905): - return TEMP_NOT_IN_OP_RANGE_STRING; - case(7101): - return FDIR_CHANGED_STATE_STRING; - case(7102): - return FDIR_STARTS_RECOVERY_STRING; - case(7103): - return FDIR_TURNS_OFF_DEVICE_STRING; - case(7201): - return MONITOR_CHANGED_STATE_STRING; - case(7202): - return VALUE_BELOW_LOW_LIMIT_STRING; - case(7203): - return VALUE_ABOVE_HIGH_LIMIT_STRING; - case(7204): - return VALUE_OUT_OF_RANGE_STRING; - case(7301): - return SWITCHING_TM_FAILED_STRING; - case(7400): - return CHANGING_MODE_STRING; - case(7401): - return MODE_INFO_STRING; - case(7402): - return FALLBACK_FAILED_STRING; - case(7403): - return MODE_TRANSITION_FAILED_STRING; - case(7404): - return CANT_KEEP_MODE_STRING; - case(7405): - return OBJECT_IN_INVALID_MODE_STRING; - case(7406): - return FORCING_MODE_STRING; - case(7407): - return MODE_CMD_REJECTED_STRING; - case(7506): - return HEALTH_INFO_STRING; - case(7507): - return CHILD_CHANGED_HEALTH_STRING; - case(7508): - return CHILD_PROBLEMS_STRING; - case(7509): - return OVERWRITING_HEALTH_STRING; - case(7510): - return TRYING_RECOVERY_STRING; - case(7511): - return RECOVERY_STEP_STRING; - case(7512): - return RECOVERY_DONE_STRING; - case(7900): - return RF_AVAILABLE_STRING; - case(7901): - return RF_LOST_STRING; - case(7902): - return BIT_LOCK_STRING; - case(7903): - return BIT_LOCK_LOST_STRING; - case(7905): - return FRAME_PROCESSING_FAILED_STRING; - case(8900): - return CLOCK_SET_STRING; - case(8901): - return CLOCK_SET_FAILURE_STRING; - case(9700): - return TEST_STRING; - case(10600): - return CHANGE_OF_SETUP_PARAMETER_STRING; - case(11101): - return MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11102): - return ACK_FAILURE_STRING; - case(11103): - return EXE_FAILURE_STRING; - case(11104): - return CRC_FAILURE_EVENT_STRING; - default: - return "UNKNOWN_EVENT"; - } - return 0; +const char *translateEvents(Event event) { + switch ((event & 0xffff)) { + case (2200): + return STORE_SEND_WRITE_FAILED_STRING; + case (2201): + return STORE_WRITE_FAILED_STRING; + case (2202): + return STORE_SEND_READ_FAILED_STRING; + case (2203): + return STORE_READ_FAILED_STRING; + case (2204): + return UNEXPECTED_MSG_STRING; + case (2205): + return STORING_FAILED_STRING; + case (2206): + return TM_DUMP_FAILED_STRING; + case (2207): + return STORE_INIT_FAILED_STRING; + case (2208): + return STORE_INIT_EMPTY_STRING; + case (2209): + return STORE_CONTENT_CORRUPTED_STRING; + case (2210): + return STORE_INITIALIZE_STRING; + case (2211): + return INIT_DONE_STRING; + case (2212): + return DUMP_FINISHED_STRING; + case (2213): + return DELETION_FINISHED_STRING; + case (2214): + return DELETION_FAILED_STRING; + case (2215): + return AUTO_CATALOGS_SENDING_FAILED_STRING; + case (2600): + return GET_DATA_FAILED_STRING; + case (2601): + return STORE_DATA_FAILED_STRING; + case (2800): + return DEVICE_BUILDING_COMMAND_FAILED_STRING; + case (2801): + return DEVICE_SENDING_COMMAND_FAILED_STRING; + case (2802): + return DEVICE_REQUESTING_REPLY_FAILED_STRING; + case (2803): + return DEVICE_READING_REPLY_FAILED_STRING; + case (2804): + return DEVICE_INTERPRETING_REPLY_FAILED_STRING; + case (2805): + return DEVICE_MISSED_REPLY_STRING; + case (2806): + return DEVICE_UNKNOWN_REPLY_STRING; + case (2807): + return DEVICE_UNREQUESTED_REPLY_STRING; + case (2808): + return INVALID_DEVICE_COMMAND_STRING; + case (2809): + return MONITORING_LIMIT_EXCEEDED_STRING; + case (2810): + return MONITORING_AMBIGUOUS_STRING; + case (4201): + return FUSE_CURRENT_HIGH_STRING; + case (4202): + return FUSE_WENT_OFF_STRING; + case (4204): + return POWER_ABOVE_HIGH_LIMIT_STRING; + case (4205): + return POWER_BELOW_LOW_LIMIT_STRING; + case (4300): + return SWITCH_WENT_OFF_STRING; + case (5000): + return HEATER_ON_STRING; + case (5001): + return HEATER_OFF_STRING; + case (5002): + return HEATER_TIMEOUT_STRING; + case (5003): + return HEATER_STAYED_ON_STRING; + case (5004): + return HEATER_STAYED_OFF_STRING; + case (5200): + return TEMP_SENSOR_HIGH_STRING; + case (5201): + return TEMP_SENSOR_LOW_STRING; + case (5202): + return TEMP_SENSOR_GRADIENT_STRING; + case (5901): + return COMPONENT_TEMP_LOW_STRING; + case (5902): + return COMPONENT_TEMP_HIGH_STRING; + case (5903): + return COMPONENT_TEMP_OOL_LOW_STRING; + case (5904): + return COMPONENT_TEMP_OOL_HIGH_STRING; + case (5905): + return TEMP_NOT_IN_OP_RANGE_STRING; + case (7101): + return FDIR_CHANGED_STATE_STRING; + case (7102): + return FDIR_STARTS_RECOVERY_STRING; + case (7103): + return FDIR_TURNS_OFF_DEVICE_STRING; + case (7201): + return MONITOR_CHANGED_STATE_STRING; + case (7202): + return VALUE_BELOW_LOW_LIMIT_STRING; + case (7203): + return VALUE_ABOVE_HIGH_LIMIT_STRING; + case (7204): + return VALUE_OUT_OF_RANGE_STRING; + case (7301): + return SWITCHING_TM_FAILED_STRING; + case (7400): + return CHANGING_MODE_STRING; + case (7401): + return MODE_INFO_STRING; + case (7402): + return FALLBACK_FAILED_STRING; + case (7403): + return MODE_TRANSITION_FAILED_STRING; + case (7404): + return CANT_KEEP_MODE_STRING; + case (7405): + return OBJECT_IN_INVALID_MODE_STRING; + case (7406): + return FORCING_MODE_STRING; + case (7407): + return MODE_CMD_REJECTED_STRING; + case (7506): + return HEALTH_INFO_STRING; + case (7507): + return CHILD_CHANGED_HEALTH_STRING; + case (7508): + return CHILD_PROBLEMS_STRING; + case (7509): + return OVERWRITING_HEALTH_STRING; + case (7510): + return TRYING_RECOVERY_STRING; + case (7511): + return RECOVERY_STEP_STRING; + case (7512): + return RECOVERY_DONE_STRING; + case (7900): + return RF_AVAILABLE_STRING; + case (7901): + return RF_LOST_STRING; + case (7902): + return BIT_LOCK_STRING; + case (7903): + return BIT_LOCK_LOST_STRING; + case (7905): + return FRAME_PROCESSING_FAILED_STRING; + case (8900): + return CLOCK_SET_STRING; + case (8901): + return CLOCK_SET_FAILURE_STRING; + case (9700): + return TEST_STRING; + case (10600): + return CHANGE_OF_SETUP_PARAMETER_STRING; + case (11101): + return MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11102): + return ACK_FAILURE_STRING; + case (11103): + return EXE_FAILURE_STRING; + case (11104): + return CRC_FAILURE_EVENT_STRING; + default: + return "UNKNOWN_EVENT"; + } + return 0; } diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.h b/bsp_hosted/fsfwconfig/events/translateEvents.h index 9034dcf2..a42d9b5a 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.h +++ b/bsp_hosted/fsfwconfig/events/translateEvents.h @@ -3,6 +3,6 @@ #include -const char * translateEvents(Event event); +const char* translateEvents(Event event); #endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ diff --git a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp index 36ef1b73..fa1c4877 100644 --- a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp +++ b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.cpp @@ -1,11 +1,10 @@ #include "MissionMessageTypes.h" + #include void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } + switch (message->getMessageType()) { + default: + break; + } } - - diff --git a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h index 7e3c448f..1d93ba21 100644 --- a/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h +++ b/bsp_hosted/fsfwconfig/ipc/MissionMessageTypes.h @@ -13,10 +13,10 @@ class CommandMessage; */ namespace messagetypes { enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, }; void clearMissionMessage(CommandMessage* message); -} +} // namespace messagetypes #endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/bsp_hosted/fsfwconfig/objects/systemObjectList.h b/bsp_hosted/fsfwconfig/objects/systemObjectList.h index 21a5f939..91bd2bed 100644 --- a/bsp_hosted/fsfwconfig/objects/systemObjectList.h +++ b/bsp_hosted/fsfwconfig/objects/systemObjectList.h @@ -1,31 +1,32 @@ #ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#include #include +#include + // The objects will be instantiated in the ID order namespace objects { - enum sourceObjects: uint32_t { +enum sourceObjects : uint32_t { - PUS_SERVICE_3 = 0x51000300, - PUS_SERVICE_5 = 0x51000400, - PUS_SERVICE_6 = 0x51000500, - PUS_SERVICE_8 = 0x51000800, - PUS_SERVICE_23 = 0x51002300, - PUS_SERVICE_201 = 0x51020100, + PUS_SERVICE_3 = 0x51000300, + PUS_SERVICE_5 = 0x51000400, + PUS_SERVICE_6 = 0x51000500, + PUS_SERVICE_8 = 0x51000800, + PUS_SERVICE_23 = 0x51002300, + PUS_SERVICE_201 = 0x51020100, - TM_FUNNEL = 0x52000002, + TM_FUNNEL = 0x52000002, - /* Test Task */ + /* Test Task */ - TEST_TASK = 0x42694269, - DUMMY_INTERFACE = 0xCAFECAFE, - DUMMY_HANDLER = 0x4400AFFE, + TEST_TASK = 0x42694269, + DUMMY_INTERFACE = 0xCAFECAFE, + DUMMY_HANDLER = 0x4400AFFE, - /* 0x49 ('I') for Communication Interfaces **/ - ARDUINO_COM_IF = 0x49000001 - }; + /* 0x49 ('I') for Communication Interfaces **/ + ARDUINO_COM_IF = 0x49000001 +}; } #endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index 9aac2b47..f29e4d65 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -1,4 +1,4 @@ -/** +/** * @brief Auto-generated object translation file. * @details * Contains 31 translations. @@ -38,72 +38,72 @@ const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END"; const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; -const char* translateObject(object_id_t object) { - switch( (object & 0xFFFFFFFF) ) { - case 0x42694269: - return TEST_TASK_STRING; - case 0x4400AFFE: - return DUMMY_HANDLER_STRING; - case 0x49000001: - return ARDUINO_COM_IF_STRING; - case 0x51000300: - return PUS_SERVICE_3_STRING; - case 0x51000400: - return PUS_SERVICE_5_STRING; - case 0x51000500: - return PUS_SERVICE_6_STRING; - case 0x51000800: - return PUS_SERVICE_8_STRING; - case 0x51002300: - return PUS_SERVICE_23_STRING; - case 0x51020100: - return PUS_SERVICE_201_STRING; - case 0x52000002: - return TM_FUNNEL_STRING; - case 0x53000000: - return FSFW_OBJECTS_START_STRING; - case 0x53000001: - return PUS_SERVICE_1_VERIFICATION_STRING; - case 0x53000002: - return PUS_SERVICE_2_DEVICE_ACCESS_STRING; - case 0x53000003: - return PUS_SERVICE_3_HOUSEKEEPING_STRING; - case 0x53000005: - return PUS_SERVICE_5_EVENT_REPORTING_STRING; - case 0x53000008: - return PUS_SERVICE_8_FUNCTION_MGMT_STRING; - case 0x53000009: - return PUS_SERVICE_9_TIME_MGMT_STRING; - case 0x53000017: - return PUS_SERVICE_17_TEST_STRING; - case 0x53000020: - return PUS_SERVICE_20_PARAMETERS_STRING; - case 0x53000200: - return PUS_SERVICE_200_MODE_MGMT_STRING; - case 0x53010000: - return HEALTH_TABLE_STRING; - case 0x53010100: - return MODE_STORE_STRING; - case 0x53030000: - return EVENT_MANAGER_STRING; - case 0x53040000: - return INTERNAL_ERROR_REPORTER_STRING; - case 0x534f0100: - return TC_STORE_STRING; - case 0x534f0200: - return TM_STORE_STRING; - case 0x534f0300: - return IPC_STORE_STRING; - case 0x53500010: - return TIME_STAMPER_STRING; - case 0x53ffffff: - return FSFW_OBJECTS_END_STRING; - case 0xCAFECAFE: - return DUMMY_INTERFACE_STRING; - case 0xFFFFFFFF: - return NO_OBJECT_STRING; - default: - return "UNKNOWN_OBJECT"; - } - return 0; +const char *translateObject(object_id_t object) { + switch ((object & 0xFFFFFFFF)) { + case 0x42694269: + return TEST_TASK_STRING; + case 0x4400AFFE: + return DUMMY_HANDLER_STRING; + case 0x49000001: + return ARDUINO_COM_IF_STRING; + case 0x51000300: + return PUS_SERVICE_3_STRING; + case 0x51000400: + return PUS_SERVICE_5_STRING; + case 0x51000500: + return PUS_SERVICE_6_STRING; + case 0x51000800: + return PUS_SERVICE_8_STRING; + case 0x51002300: + return PUS_SERVICE_23_STRING; + case 0x51020100: + return PUS_SERVICE_201_STRING; + case 0x52000002: + return TM_FUNNEL_STRING; + case 0x53000000: + return FSFW_OBJECTS_START_STRING; + case 0x53000001: + return PUS_SERVICE_1_VERIFICATION_STRING; + case 0x53000002: + return PUS_SERVICE_2_DEVICE_ACCESS_STRING; + case 0x53000003: + return PUS_SERVICE_3_HOUSEKEEPING_STRING; + case 0x53000005: + return PUS_SERVICE_5_EVENT_REPORTING_STRING; + case 0x53000008: + return PUS_SERVICE_8_FUNCTION_MGMT_STRING; + case 0x53000009: + return PUS_SERVICE_9_TIME_MGMT_STRING; + case 0x53000017: + return PUS_SERVICE_17_TEST_STRING; + case 0x53000020: + return PUS_SERVICE_20_PARAMETERS_STRING; + case 0x53000200: + return PUS_SERVICE_200_MODE_MGMT_STRING; + case 0x53010000: + return HEALTH_TABLE_STRING; + case 0x53010100: + return MODE_STORE_STRING; + case 0x53030000: + return EVENT_MANAGER_STRING; + case 0x53040000: + return INTERNAL_ERROR_REPORTER_STRING; + case 0x534f0100: + return TC_STORE_STRING; + case 0x534f0200: + return TM_STORE_STRING; + case 0x534f0300: + return IPC_STORE_STRING; + case 0x53500010: + return TIME_STAMPER_STRING; + case 0x53ffffff: + return FSFW_OBJECTS_END_STRING; + case 0xCAFECAFE: + return DUMMY_INTERFACE_STRING; + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; } diff --git a/bsp_hosted/fsfwconfig/returnvalues/classIds.h b/bsp_hosted/fsfwconfig/returnvalues/classIds.h index cc159fec..b50e8ac0 100644 --- a/bsp_hosted/fsfwconfig/returnvalues/classIds.h +++ b/bsp_hosted/fsfwconfig/returnvalues/classIds.h @@ -1,9 +1,10 @@ #ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ #define CONFIG_RETURNVALUES_CLASSIDS_H_ -#include "commonClassIds.h" #include +#include "commonClassIds.h" + /** * Source IDs starts at 73 for now * Framework IDs for ReturnValues run from 0 to 56 @@ -11,9 +12,8 @@ */ namespace CLASS_ID { enum { - CLASS_ID_START = COMMON_CLASS_ID_END, + CLASS_ID_START = COMMON_CLASS_ID_END, }; } - #endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/bsp_hosted/fsfwconfig/tmtc/apid.h b/bsp_hosted/fsfwconfig/tmtc/apid.h index ee2fc7c4..9d5c9ed5 100644 --- a/bsp_hosted/fsfwconfig/tmtc/apid.h +++ b/bsp_hosted/fsfwconfig/tmtc/apid.h @@ -12,8 +12,7 @@ * APID is a 11 bit number */ namespace apid { - static const uint16_t EIVE_OBSW = 0x65; +static const uint16_t EIVE_OBSW = 0x65; } - #endif /* FSFWCONFIG_TMTC_APID_H_ */ diff --git a/bsp_hosted/fsfwconfig/tmtc/pusIds.h b/bsp_hosted/fsfwconfig/tmtc/pusIds.h index a2dd7575..37503786 100644 --- a/bsp_hosted/fsfwconfig/tmtc/pusIds.h +++ b/bsp_hosted/fsfwconfig/tmtc/pusIds.h @@ -2,21 +2,21 @@ #define CONFIG_TMTC_PUSIDS_HPP_ namespace pus { -enum Ids{ - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_3_PSB = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, +enum Ids { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_3_PSB = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, }; }; diff --git a/bsp_hosted/main.cpp b/bsp_hosted/main.cpp index 153cc447..b7ebc422 100644 --- a/bsp_hosted/main.cpp +++ b/bsp_hosted/main.cpp @@ -1,10 +1,9 @@ +#include + #include "InitMission.h" #include "OBSWVersion.h" - #include "fsfw/FSFWVersion.h" #include "fsfw/tasks/TaskFactory.h" - -#include #ifdef WIN32 static const char* COMPILE_PRINTOUT = "Windows"; #elif LINUX @@ -17,21 +16,18 @@ static const char* COMPILE_PRINTOUT = "unknown OS"; * Linux and Windows. * @return */ -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 << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; +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 << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; - initmission::initMission(); + initmission::initMission(); - for(;;) { - // suspend main thread by sleeping it. - TaskFactory::delayTask(5000); - } + for (;;) { + // suspend main thread by sleeping it. + TaskFactory::delayTask(5000); + } } - - diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index d265fded..86d5fb4b 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -1,247 +1,244 @@ #include "InitMission.h" -#include "ObjectFactory.h" -#include "objects/systemObjectList.h" -#include "OBSWConfig.h" -#include "pollingsequence/pollingSequenceFactory.h" - -#include +#include #include #include #include -#include #include #include #include +#include #include +#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"); ServiceInterfaceStream sif::error("ERROR"); -ObjectManagerIF *objectManager = nullptr; +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); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ + ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Object add component failed" << std::endl; - } + /* UDP bridge */ + PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( + "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Unix Bridge failed" << std::endl; + } + PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( + "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Add component UDP Polling failed" << std::endl; + } - /* UDP bridge */ - PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( - "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = udpBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Unix Bridge failed" << std::endl; - } - PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = udpPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Polling failed" << std::endl; - } + /* PUS Services */ + std::vector pusTasks; + createPusTasks(*factory, missedDeadlineFunc, pusTasks); - /* PUS Services */ - std::vector pusTasks; - createPusTasks(*factory, missedDeadlineFunc, pusTasks); - - std::vector pstTasks; - createPstTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector pstTasks; + createPstTasks(*factory, missedDeadlineFunc, pstTasks); #if OBSW_ADD_TEST_CODE == 1 - std::vector testTasks; - createTestTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector testTasks; + createTestTasks(*factory, missedDeadlineFunc, pstTasks); #endif /* OBSW_ADD_TEST_CODE == 1 */ - auto taskStarter = [](std::vector& taskVector, std::string name) { - for(const auto& task: taskVector) { - if(task != nullptr) { - task->startTask(); - } - else { - sif::error << "Task in vector " << name << " is invalid!" << std::endl; - } - } - }; + auto taskStarter = [](std::vector& taskVector, std::string name) { + for (const auto& task : taskVector) { + if (task != nullptr) { + task->startTask(); + } else { + sif::error << "Task in vector " << name << " is invalid!" << std::endl; + } + } + }; - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); - udpBridgeTask->startTask(); - udpPollingTask->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + udpBridgeTask->startTask(); + udpPollingTask->startTask(); - taskStarter(pusTasks, "PUS Tasks"); + taskStarter(pusTasks, "PUS Tasks"); #if OBSW_ADD_TEST_CODE == 1 - taskStarter(testTasks, "Test Tasks"); + taskStarter(testTasks, "Test Tasks"); #endif /* OBSW_ADD_TEST_CODE == 1 */ - taskStarter(pstTasks, "PST Tasks"); + taskStarter(pstTasks, "PST Tasks"); #if OBSW_ADD_TEST_PST == 1 - if(startTestPst) { - pstTestTask->startTask(); - } + if (startTestPst) { + pstTestTask->startTask(); + } #endif /* RPI_TEST_ACS_BOARD == 1 */ - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } void initmission::createPusTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector& taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - taskVec.push_back(pusVerification); + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + PeriodicTaskIF* pusVerification = factory.createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + taskVec.push_back(pusVerification); - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); - } - result = pusEvents->addComponent(objects::EVENT_MANAGER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); - } - taskVec.push_back(pusEvents); + PeriodicTaskIF* pusEvents = factory.createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); + } + result = pusEvents->addComponent(objects::EVENT_MANAGER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); + } + taskVec.push_back(pusEvents); - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); - } - taskVec.push_back(pusHighPrio); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); + } + taskVec.push_back(pusHighPrio); - PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS3", objects::PUS_SERVICE_3_HOUSEKEEPING); - } - taskVec.push_back(pusMedPrio); + PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS3", objects::PUS_SERVICE_3_HOUSEKEEPING); + } + taskVec.push_back(pusMedPrio); - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); - } - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("INT_ERR_RPRT", - objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); + PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); + } + result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("INT_ERR_RPRT", objects::INTERNAL_ERROR_REPORTER); + } + taskVec.push_back(pusLowPrio); } void initmission::createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& 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); - result = pst::pstSpi(spiPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(spiPst); + FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( + "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; + } + taskVec.push_back(spiPst); #endif } void initmission::createTestTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - PeriodicTaskIF* testTask = factory.createPeriodicTask( - "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + PeriodicTaskIF* testTask = factory.createPeriodicTask( + "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #if RPI_ADD_SPI_TEST == 1 - result = testTask->addComponent(objects::SPI_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); - } + result = testTask->addComponent(objects::SPI_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); + } #endif /* RPI_ADD_SPI_TEST == 1 */ #if RPI_ADD_GPIO_TEST == 1 - result = testTask->addComponent(objects::LIBGPIOD_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); - } + result = testTask->addComponent(objects::LIBGPIOD_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); + } #endif /* RPI_ADD_GPIO_TEST == 1 */ #if RPI_ADD_UART_TEST == 1 - result = testTask->addComponent(objects::UART_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UART_TEST", objects::UART_TEST); - } + result = testTask->addComponent(objects::UART_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UART_TEST", objects::UART_TEST); + } #endif /* RPI_ADD_GPIO_TEST == 1 */ - bool startTestPst = true; - static_cast(startTestPst); + bool startTestPst = true; + static_cast(startTestPst); #if OBSW_ADD_TEST_PST == 1 - 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; - } + 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 */ - } diff --git a/bsp_linux_board/InitMission.h b/bsp_linux_board/InitMission.h index f5da5855..f14135dd 100644 --- a/bsp_linux_board/InitMission.h +++ b/bsp_linux_board/InitMission.h @@ -1,9 +1,10 @@ #ifndef BSP_LINUX_INITMISSION_H_ #define BSP_LINUX_INITMISSION_H_ -#include "fsfw/tasks/Typedef.h" #include +#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, - std::vector &taskVec); -void createTestTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector &taskVec); +void createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec); +void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec); void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); -}; + std::vector& taskVec); +}; // namespace initmission #endif /* BSP_LINUX_INITMISSION_H_ */ diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index bb86ecce..71966164 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,236 +1,241 @@ -#include #include "ObjectFactory.h" -#include "objects/systemObjectList.h" +#include +#include + +#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 #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 #include #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 #include +#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; + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } - - -void ObjectFactory::produce(void* args){ - Factory::setStaticFrameworkObjectIds(); - ObjectFactory::produceGenericObjects(); +void ObjectFactory::produce(void* args) { + Factory::setStaticFrameworkObjectIds(); + ObjectFactory::produceGenericObjects(); #if OBSW_USE_TMTC_TCP_BRIDGE == 1 - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); #else - auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); #endif - GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); - GpioCookie* gpioCookie = nullptr; - static_cast(gpioCookie); + GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); + GpioCookie* gpioCookie = nullptr; + static_cast(gpioCookie); - new SpiComIF(objects::SPI_COM_IF, gpioIF); + new SpiComIF(objects::SPI_COM_IF, gpioIF); - std::string spiDev; - SpiCookie* spiCookie = nullptr; - static_cast(spiCookie); + std::string spiDev; + SpiCookie* spiCookie = nullptr; + static_cast(spiCookie); #if OBSW_ADD_ACS_BOARD == 1 - if(gpioCookie == nullptr) { - 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_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_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_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); - gpioIF->addGpios(gpioCookie); + if (gpioCookie == nullptr) { + 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_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_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_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); + gpioIF->addGpios(gpioCookie); - spiDev = "/dev/spidev0.1"; - 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); - mgmLis3Handler->setStartUpImmediately(); + spiDev = "/dev/spidev0.1"; + 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); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - 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); - mgmRm3100Handler->setStartUpImmediately(); + 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); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - 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->setStartUpImmediately(); + 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->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - 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->setStartUpImmediately(); + 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->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - 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); - 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); - gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG== 1 - gyroL3gHandler->setToGoToNormalMode(true); + 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); + 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); + 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, - 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->setStartUpImmediately(); + 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->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); - gyroL3gHandler->setStartUpImmediately(); -#if FSFW_HAL_L3GD20_GYRO_DEBUG== 1 - gyroL3gHandler->setToGoToNormalMode(true); + 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); #endif #endif /* RPI_TEST_ACS_BOARD == 1 */ #if OBSW_ADD_TEST_CODE == 1 - createTestTasks(); + createTestTasks(); #endif /* OBSW_ADD_TEST_CODE == 1 */ } void ObjectFactory::createTestTasks() { - - new TestTask(objects::TEST_TASK); + new TestTask(objects::TEST_TASK); #if RPI_ADD_SPI_TEST == 1 - new SpiTestClass(objects::SPI_TEST, gpioIF); + new SpiTestClass(objects::SPI_TEST, gpioIF); #endif #if RPI_ADD_UART_TEST == 1 - new UartTestClass(objects::UART_TEST); + new UartTestClass(objects::UART_TEST); #else - new UartComIF(objects::UART_COM_IF); + new UartComIF(objects::UART_COM_IF); #endif #if RPI_LOOPBACK_TEST_GPIO == 1 - GpioCookie* gpioCookieLoopback = new GpioCookie(); - /* Loopback pins. Adapt according to setup */ - gpioId_t gpioIdSender = gpioIds::TEST_ID_0; - int bcmPinSender = 26; - gpioId_t gpioIdReader = gpioIds::TEST_ID_1; - int bcmPinReader = 16; - gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdSender, bcmPinSender, "GPIO_LB_SENDER", - gpio::Direction::OUT, 0); - gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdReader, bcmPinReader, "GPIO_LB_READER", - gpio::Direction::IN, 0); - new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); + GpioCookie* gpioCookieLoopback = new GpioCookie(); + /* Loopback pins. Adapt according to setup */ + gpioId_t gpioIdSender = gpioIds::TEST_ID_0; + int bcmPinSender = 26; + gpioId_t gpioIdReader = gpioIds::TEST_ID_1; + int bcmPinReader = 16; + gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdSender, bcmPinSender, "GPIO_LB_SENDER", + gpio::Direction::OUT, 0); + gpio::createRpiGpioConfig(gpioCookieLoopback, gpioIdReader, bcmPinReader, "GPIO_LB_READER", + gpio::Direction::IN, 0); + new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); #endif /* RPI_LOOPBACK_TEST_GPIO == 1 */ #if RPI_TEST_ADIS16507 == 1 - if(gpioCookie == nullptr) { - gpioCookie = new GpioCookie(); - } - gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, - "GYRO_0_ADIS", gpio::Direction::OUT, 1); - gpioIF->addGpios(gpioCookie); + if (gpioCookie == nullptr) { + gpioCookie = new GpioCookie(); + } + gpio::createRpiGpioConfig(gpioCookie, gpioIds::GYRO_0_ADIS_CS, gpio::GYRO_0_BCM_PIN, + "GYRO_0_ADIS", gpio::Direction::OUT, 1); + gpioIF->addGpios(gpioCookie); - 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); - adisGyroHandler->setStartUpImmediately(); + 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); + 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->setToFlushInput(true); - uartCookie->setReadCycles(6); - GPSHyperionHandler* gpsHandler = new GPSHyperionHandler(objects::GPS0_HANDLER, - objects::UART_COM_IF, uartCookie, false); - gpsHandler->setStartUpImmediately(); + 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); + gpsHandler->setStartUpImmediately(); #endif - } diff --git a/bsp_linux_board/ObjectFactory.h b/bsp_linux_board/ObjectFactory.h index 3b9aca49..909baf06 100644 --- a/bsp_linux_board/ObjectFactory.h +++ b/bsp_linux_board/ObjectFactory.h @@ -1,12 +1,11 @@ #ifndef BSP_LINUX_OBJECTFACTORY_H_ #define BSP_LINUX_OBJECTFACTORY_H_ - namespace ObjectFactory { - void setStatics(); - void produce(void* args); +void setStatics(); +void produce(void* args); - void createTestTasks(); -}; +void createTestTasks(); +}; // namespace ObjectFactory #endif /* BSP_LINUX_OBJECTFACTORY_H_ */ diff --git a/bsp_linux_board/boardconfig/etl_profile.h b/bsp_linux_board/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_linux_board/boardconfig/etl_profile.h +++ b/bsp_linux_board/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_linux_board/boardconfig/gcov.h b/bsp_linux_board/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_linux_board/boardconfig/gcov.h +++ b/bsp_linux_board/boardconfig/gcov.h @@ -6,8 +6,9 @@ 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; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_linux_board/boardconfig/print.c b/bsp_linux_board/boardconfig/print.c index c501e0b7..3aba2d73 100644 --- a/bsp_linux_board/boardconfig/print.c +++ b/bsp_linux_board/boardconfig/print.c @@ -2,13 +2,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_linux_board/main.cpp b/bsp_linux_board/main.cpp index a766f2a0..4e286f5d 100644 --- a/bsp_linux_board/main.cpp +++ b/bsp_linux_board/main.cpp @@ -1,12 +1,11 @@ +#include + #include "InitMission.h" #include "OBSWConfig.h" #include "OBSWVersion.h" - #include "fsfw/FSFWVersion.h" #include "fsfw/tasks/TaskFactory.h" -#include - #ifdef RASPBERRY_PI static const char* const BOARD_NAME = "Raspberry Pi"; #elif defined(BEAGLEBONEBLACK) @@ -19,21 +18,18 @@ 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) -{ - 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 << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; +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 << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; - initmission::initMission(); + initmission::initMission(); - for(;;) { - /* Suspend main thread by sleeping it. */ - TaskFactory::delayTask(5000); - } + for (;;) { + /* Suspend main thread by sleeping it. */ + TaskFactory::delayTask(5000); + } } - - diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 34516fa6..e41ed093 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -19,58 +19,58 @@ static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; static constexpr char UIO_PDEC_RAM[] = "/dev/uio3"; namespace gpioNames { - static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; - static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; - static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; - static constexpr char GYRO_3_L3G_CS[] = "gyro_3_l3g_chip_select"; - static constexpr char MGM_0_CS[] = "mgm_0_lis3_chip_select"; - static constexpr char MGM_1_CS[] = "mgm_1_rm3100_chip_select"; - static constexpr char MGM_2_CS[] = "mgm_2_lis3_chip_select"; - static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; - static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; - static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; - static constexpr char GNSS_0_ENABLE[] = "enable_gnss_0"; - static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; - static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; - static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; - static constexpr char HEATER_0[] = "heater0"; - static constexpr char HEATER_1[] = "heater1"; - static constexpr char HEATER_2[] = "heater2"; - static constexpr char HEATER_3[] = "heater3"; - static constexpr char HEATER_4[] = "heater4"; - static constexpr char HEATER_5[] = "heater5"; - static constexpr char HEATER_6[] = "heater6"; - static constexpr char HEATER_7[] = "heater7"; - static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; - static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; - static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; - static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; - static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; - static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; - static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; - static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; - static constexpr char EN_RW_CS[] = "en_rw_cs"; - static constexpr char EN_RW_1[] = "enable_rw_1"; - static constexpr char EN_RW_2[] = "enable_rw_2"; - static constexpr char EN_RW_3[] = "enable_rw_3"; - static constexpr char EN_RW_4[] = "enable_rw_4"; - static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; - static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; - static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; - static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; - static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; - static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; - static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; - static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; - static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; - static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; - static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; - static constexpr char RS485_EN_TX_DATA[] = "tx_data_enable_ltc2872"; - static constexpr char RS485_EN_RX_CLOCK[] = "rx_clock_enable_ltc2872"; - 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"; -} -} +static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; +static constexpr char GYRO_1_L3G_CS[] = "gyro_1_l3g_chip_select"; +static constexpr char GYRO_2_ADIS_CS[] = "gyro_2_adis_chip_select"; +static constexpr char GYRO_3_L3G_CS[] = "gyro_3_l3g_chip_select"; +static constexpr char MGM_0_CS[] = "mgm_0_lis3_chip_select"; +static constexpr char MGM_1_CS[] = "mgm_1_rm3100_chip_select"; +static constexpr char MGM_2_CS[] = "mgm_2_lis3_chip_select"; +static constexpr char MGM_3_CS[] = "mgm_3_rm3100_chip_select"; +static constexpr char RESET_GNSS_0[] = "reset_gnss_0"; +static constexpr char RESET_GNSS_1[] = "reset_gnss_1"; +static constexpr char GNSS_0_ENABLE[] = "enable_gnss_0"; +static constexpr char GNSS_1_ENABLE[] = "enable_gnss_1"; +static constexpr char GYRO_0_ENABLE[] = "enable_gyro_0"; +static constexpr char GYRO_2_ENABLE[] = "enable_gyro_2"; +static constexpr char HEATER_0[] = "heater0"; +static constexpr char HEATER_1[] = "heater1"; +static constexpr char HEATER_2[] = "heater2"; +static constexpr char HEATER_3[] = "heater3"; +static constexpr char HEATER_4[] = "heater4"; +static constexpr char HEATER_5[] = "heater5"; +static constexpr char HEATER_6[] = "heater6"; +static constexpr char HEATER_7[] = "heater7"; +static constexpr char SA_DPL_PIN_0[] = "sa_dpl_0"; +static constexpr char SA_DPL_PIN_1[] = "sa_dpl_1"; +static constexpr char SPI_MUX_BIT_1_PIN[] = "spi_mux_bit_1"; +static constexpr char SPI_MUX_BIT_2_PIN[] = "spi_mux_bit_2"; +static constexpr char SPI_MUX_BIT_3_PIN[] = "spi_mux_bit_3"; +static constexpr char SPI_MUX_BIT_4_PIN[] = "spi_mux_bit_4"; +static constexpr char SPI_MUX_BIT_5_PIN[] = "spi_mux_bit_5"; +static constexpr char SPI_MUX_BIT_6_PIN[] = "spi_mux_bit_6"; +static constexpr char EN_RW_CS[] = "en_rw_cs"; +static constexpr char EN_RW_1[] = "enable_rw_1"; +static constexpr char EN_RW_2[] = "enable_rw_2"; +static constexpr char EN_RW_3[] = "enable_rw_3"; +static constexpr char EN_RW_4[] = "enable_rw_4"; +static constexpr char GNSS_MUX_SELECT[] = "gnss_mux_select"; +static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; +static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; +static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; +static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; +static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; +static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; +static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; +static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; +static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; +static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; +static constexpr char RS485_EN_TX_DATA[] = "tx_data_enable_ltc2872"; +static constexpr char RS485_EN_RX_CLOCK[] = "rx_clock_enable_ltc2872"; +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_ */ diff --git a/bsp_q7s/boardconfig/etl_profile.h b/bsp_q7s/boardconfig/etl_profile.h index c35ffb46..54aca344 100644 --- a/bsp_q7s/boardconfig/etl_profile.h +++ b/bsp_q7s/boardconfig/etl_profile.h @@ -32,7 +32,7 @@ SOFTWARE. #define ETL_CHECK_PUSH_POP -#define ETL_CPP11_SUPPORTED 1 -#define ETL_NO_NULLPTR_SUPPORT 0 +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 #endif diff --git a/bsp_q7s/boardconfig/gcov.h b/bsp_q7s/boardconfig/gcov.h index 491d24c6..80acdd86 100644 --- a/bsp_q7s/boardconfig/gcov.h +++ b/bsp_q7s/boardconfig/gcov.h @@ -6,8 +6,9 @@ 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; + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" + << std::flush; } #endif diff --git a/bsp_q7s/boardconfig/print.c b/bsp_q7s/boardconfig/print.c index c501e0b7..3aba2d73 100644 --- a/bsp_q7s/boardconfig/print.c +++ b/bsp_q7s/boardconfig/print.c @@ -2,13 +2,9 @@ #include void printChar(const char* character, bool errStream) { - if(errStream) { - putc(*character, stderr); - return; - } - putc(*character, stdout); + if (errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); } - - - - diff --git a/bsp_q7s/boardtest/FileSystemTest.cpp b/bsp_q7s/boardtest/FileSystemTest.cpp index 92c4cf3d..e1dd564d 100644 --- a/bsp_q7s/boardtest/FileSystemTest.cpp +++ b/bsp_q7s/boardtest/FileSystemTest.cpp @@ -1,26 +1,23 @@ #include "FileSystemTest.h" + +#include +#include + #include "fsfw/timemanager/Stopwatch.h" -#include -#include - -enum SdCard { - SDC0, - SDC1 -}; +enum SdCard { SDC0, SDC1 }; FileSystemTest::FileSystemTest() { - using namespace std; - SdCard sdCard = SdCard::SDC0; - cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; - //Stopwatch stopwatch; - std::system("q7hw sd info all > /tmp/sd_status.txt"); - //stopwatch.stop(true); - std::system("q7hw sd set 0 on > /tmp/sd_set.txt"); - //stopwatch.stop(true); - std::system("q7hw sd set 0 off > /tmp/sd_set.txt"); - //stopwatch.stop(true); + using namespace std; + SdCard sdCard = SdCard::SDC0; + cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; + // Stopwatch stopwatch; + std::system("q7hw sd info all > /tmp/sd_status.txt"); + // stopwatch.stop(true); + std::system("q7hw sd set 0 on > /tmp/sd_set.txt"); + // stopwatch.stop(true); + std::system("q7hw sd set 0 off > /tmp/sd_set.txt"); + // stopwatch.stop(true); } -FileSystemTest::~FileSystemTest() { -} +FileSystemTest::~FileSystemTest() {} diff --git a/bsp_q7s/boardtest/FileSystemTest.h b/bsp_q7s/boardtest/FileSystemTest.h index 256a0b36..bdb7989f 100644 --- a/bsp_q7s/boardtest/FileSystemTest.h +++ b/bsp_q7s/boardtest/FileSystemTest.h @@ -2,12 +2,11 @@ #define BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ class FileSystemTest { -public: - FileSystemTest(); - virtual~ FileSystemTest(); -private: + public: + FileSystemTest(); + virtual ~FileSystemTest(); + + private: }; - - #endif /* BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ */ diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index dc87cd3b..5d9042ac 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -1,414 +1,397 @@ +#include "Q7STestTask.h" + #include #include #include -#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 #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include -Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) { - doTestSdCard = false; - doTestScratchApi = false; - doTestGps = false; +#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; + doTestScratchApi = false; + doTestGps = false; } ReturnValue_t Q7STestTask::performOneShotAction() { - if (doTestSdCard) { - testSdCard(); - } - if (doTestScratchApi) { - testScratchApi(); - } - //testJsonLibDirect(); - //testDummyParams(); - //testProtHandler(); - FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE; - testFileSystemHandlerDirect(opCode); - return TestTask::performOneShotAction(); + if (doTestSdCard) { + testSdCard(); + } + if (doTestScratchApi) { + testScratchApi(); + } + // testJsonLibDirect(); + // testDummyParams(); + // testProtHandler(); + FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE; + testFileSystemHandlerDirect(opCode); + return TestTask::performOneShotAction(); } ReturnValue_t Q7STestTask::performPeriodicAction() { - if(doTestGps) { - testGpsDaemon(); - } - return TestTask::performPeriodicAction(); + if (doTestGps) { + testGpsDaemon(); + } + return TestTask::performPeriodicAction(); } void Q7STestTask::testSdCard() { - using namespace std; - Stopwatch stopwatch; - int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); - if(result != 0) { - sif::debug << "system call failed with " << result << endl; + using namespace std; + Stopwatch stopwatch; + int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); + if (result != 0) { + sif::debug << "system call failed with " << result << endl; + } + ifstream sdStatus("/tmp/sd_status.txt"); + string line; + uint8_t idx = 0; + while (std::getline(sdStatus, line)) { + std::istringstream iss(line); + string word; + while (iss >> word) { + if (word == "on") { + sif::info << "SD card " << static_cast(idx) << " is on" << endl; + } else if (word == "off") { + sif::info << "SD card " << static_cast(idx) << " is off" << endl; + } } - ifstream sdStatus("/tmp/sd_status.txt"); - string line; - uint8_t idx = 0; - while (std::getline(sdStatus, line)) { - std::istringstream iss(line); - string word; - while(iss >> word) { - if(word == "on") { - sif::info << "SD card " << static_cast(idx) << " is on" << endl; - } - else if(word == "off") { - sif::info << "SD card " << static_cast(idx) << " is off" << endl; - } - } - idx++; - } - std::remove("/tmp/sd_status.txt"); + idx++; + } + std::remove("/tmp/sd_status.txt"); } void Q7STestTask::fileTests() { - using namespace std; - ofstream testFile("/tmp/test.txt"); - testFile << "Hallo Welt" << endl; - testFile.close(); + using namespace std; + ofstream testFile("/tmp/test.txt"); + testFile << "Hallo Welt" << endl; + testFile.close(); - system("echo \"Hallo Welt\" > /tmp/test2.txt"); - system("echo \"Hallo Welt\""); + system("echo \"Hallo Welt\" > /tmp/test2.txt"); + system("echo \"Hallo Welt\""); } void Q7STestTask::testScratchApi() { - ReturnValue_t result = scratch::writeNumber("TEST", 1); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Writing number failed" << std::endl; - } - int number = 0; - result = scratch::readNumber("TEST", number); - sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST\": " << number << std::endl; - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; - } + ReturnValue_t result = scratch::writeNumber("TEST", 1); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Writing number failed" << std::endl; + } + int number = 0; + result = scratch::readNumber("TEST", number); + sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST\": " << number << std::endl; + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; + } - result = scratch::writeString("TEST2", "halloWelt"); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Writing string failed" << std::endl; - } - std::string string; - result = scratch::readString("TEST2", string); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; - } - sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST2\": " << string << std::endl; + result = scratch::writeString("TEST2", "halloWelt"); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Writing string failed" << std::endl; + } + std::string string; + result = scratch::readString("TEST2", string); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; + } + sif::info << "Q7STestTask::testScratchApi: Value for key \"TEST2\": " << string << std::endl; - result = scratch::clearValue("TEST"); - result = scratch::clearValue("TEST2"); + result = scratch::clearValue("TEST"); + result = scratch::clearValue("TEST2"); } void Q7STestTask::testJsonLibDirect() { - Stopwatch stopwatch; - // for convenience - using json = nlohmann::json; - json helloTest; - // add a number that is stored as double (note the implicit conversion of j to an object) - helloTest["pi"] = 3.141; - std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - std::string fileName = mntPrefix + "/pretty.json"; - std::ofstream o(fileName); - o << std::setw(4) << helloTest << std::endl; + Stopwatch stopwatch; + // for convenience + using json = nlohmann::json; + json helloTest; + // add a number that is stored as double (note the implicit conversion of j to an object) + helloTest["pi"] = 3.141; + std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::string fileName = mntPrefix + "/pretty.json"; + std::ofstream o(fileName); + o << std::setw(4) << helloTest << std::endl; } void Q7STestTask::testDummyParams() { - std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - DummyParameter param(mntPrefix, "dummy_json.txt"); - param.printKeys(); - param.print(); - if(not param.getJsonFileExists()) { - param.writeJsonFile(); - } - - ReturnValue_t result = param.readJsonFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - - } - - param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3); - param.setValue(DummyParameter::DUMMY_KEY_PARAM_2, "blirb"); - + std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + DummyParameter param(mntPrefix, "dummy_json.txt"); + param.printKeys(); + param.print(); + if (not param.getJsonFileExists()) { param.writeJsonFile(); - param.print(); + } - int test = 0; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 - << " does not exist" << std::endl; - } - std::string test2; - result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 - << " does not exist" << std::endl; - } - sif::info << "Test value (3 expected): " << test << std::endl; - sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; + ReturnValue_t result = param.readJsonFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + } + + param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3); + param.setValue(DummyParameter::DUMMY_KEY_PARAM_2, "blirb"); + + param.writeJsonFile(); + param.print(); + + int test = 0; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_1, &test); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } + std::string test2; + result = param.getValue(DummyParameter::DUMMY_KEY_PARAM_2, &test2); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1 + << " does not exist" << std::endl; + } + sif::info << "Test value (3 expected): " << test << std::endl; + sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; } ReturnValue_t Q7STestTask::initialize() { - coreController = ObjectManager::instance()->get(objects::CORE_CONTROLLER); - if(coreController == nullptr) { - sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" << - std::endl; - } - return TestTask::initialize(); + coreController = ObjectManager::instance()->get(objects::CORE_CONTROLLER); + if (coreController == nullptr) { + sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" + << std::endl; + } + return TestTask::initialize(); } void Q7STestTask::testProtHandler() { - bool opPerformed = false; - 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); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } + bool opPerformed = false; + 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); + 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); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - int retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // unlock own copy + result = coreController->setBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + int retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // lock own copy - result = coreController->setBootCopyProtection( - CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // lock own copy + result = coreController->setBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // unlock specific copy - result = coreController->setBootCopyProtection( - CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // unlock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } - // lock specific copy - result = coreController->setBootCopyProtection( - CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, - opPerformed, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; - } - if(not opPerformed) { - sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; - } - retval = std::system("print-chip-prot-status.sh"); - if(retval != 0) { - utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); - } + // lock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, opPerformed, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if (not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if (retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } } void Q7STestTask::testGpsDaemon() { - gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); - gps_data_t* gps; - gps = gpsmm.read(); - if(gps == nullptr) { - sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; - } - sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; - time_t timeRaw = gps->fix.time.tv_sec; - std::tm* time = gmtime(&timeRaw); - sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; - sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; - sif::info << "Satellites used: " << gps->satellites_used << std::endl; - sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; - sif::info << "Latitude: " << gps->fix.latitude << std::endl; - sif::info << "Longitude: " << gps->fix.longitude << std::endl; - sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; - sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; + gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); + gps_data_t* gps; + gps = gpsmm.read(); + if (gps == nullptr) { + sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; + } + sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; + time_t timeRaw = gps->fix.time.tv_sec; + std::tm* time = gmtime(&timeRaw); + sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; + sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; + sif::info << "Satellites used: " << gps->satellites_used << std::endl; + sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; + sif::info << "Latitude: " << gps->fix.latitude << std::endl; + sif::info << "Longitude: " << gps->fix.longitude << std::endl; + sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; + sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; } void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { - auto fsHandler = ObjectManager::instance()-> - get(objects::FILE_SYSTEM_HANDLER); - if(fsHandler == nullptr) { - sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.." - << std::endl; - } - FileSystemHandler::FsCommandCfg cfg = {}; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + auto fsHandler = ObjectManager::instance()->get(objects::FILE_SYSTEM_HANDLER); + if (fsHandler == nullptr) { + sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.." + << std::endl; + } + FileSystemHandler::FsCommandCfg cfg = {}; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // Lambda for common code - auto createNonEmptyTmpDir = [&]() { - if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp", "test", false, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - } - // Creating sample files - sif::info << "Creating sample files in directory" << std::endl; - result = fsHandler->createFile("/tmp/test", "test1.txt", nullptr, 0, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = fsHandler->createFile("/tmp/test", "test2.txt", nullptr, 0, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + // Lambda for common code + auto createNonEmptyTmpDir = [&]() { + if (not std::filesystem::exists("/tmp/test")) { + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { return result; - }; + } + } + // Creating sample files + sif::info << "Creating sample files in directory" << std::endl; + result = fsHandler->createFile("/tmp/test", "test1.txt", nullptr, 0, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = fsHandler->createFile("/tmp/test", "test2.txt", nullptr, 0, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return result; + }; - - switch(opCode) { - case(FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - sif::info << "Creating empty file in /tmp folder" << std::endl; - // Do not delete file, user can check existence in shell + switch (opCode) { + case (FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + sif::info << "Creating empty file in /tmp folder" << std::endl; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + break; + } + case (FsOpCodes::REMOVE_TMP_FILE): { + sif::info << "Deleting /tmp/test.txt sample file" << std::endl; + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (not std::filesystem::exists("/tmp/test.txt")) { + // Creating sample file + sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl; fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - break; + } + result = fsHandler->removeFile("/tmp", "test.txt", &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "File removed successfully" << std::endl; + } else { + sif::warning << "File removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_TMP_FILE): { - sif::info << "Deleting /tmp/test.txt sample file" << std::endl; - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(not std::filesystem::exists("/tmp/test.txt")) { - // Creating sample file - sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl; - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - } - result = fsHandler->removeFile("/tmp", "test.txt", &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "File removed successfully" << std::endl; - } - else { - sif::warning << "File removal failed!" << std::endl; - } - break; + case (FsOpCodes::CREATE_DIR_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + sif::info << "Creating empty file in /tmp folder" << std::endl; + // Do not delete file, user can check existence in shell + ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory created successfully" << std::endl; + } else { + sif::warning << "Directory creation failed!" << std::endl; + } + break; } - case(FsOpCodes::CREATE_DIR_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - sif::info << "Creating empty file in /tmp folder" << std::endl; - // Do not delete file, user can check existence in shell - ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory created successfully" << std::endl; - } - else { - sif::warning << "Directory creation failed!" << std::endl; - } - break; + case (FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (not std::filesystem::exists("/tmp/test")) { + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); + } 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 { + sif::warning << "Directory removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp", "test", false, &cfg); - } - 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 { - sif::warning << "Directory removal failed!" << std::endl; - } - break; + case (FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): { + result = createNonEmptyTmpDir(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg); + if (result == HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removed recursively successfully" << std::endl; + } else { + sif::warning << "Recursive directory removal failed!" << std::endl; + } + break; } - case(FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): { - result = createNonEmptyTmpDir(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return; - } - result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg); - if(result == HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removed recursively successfully" << std::endl; - } - else { - sif::warning << "Recursive directory removal failed!" << std::endl; - } - break; + case (FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): { + result = createNonEmptyTmpDir(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return; + } + result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::info << "Directory removal attempt failed as expected" << std::endl; + } else { + sif::warning << "Directory removal worked when it should not have!" << std::endl; + } + break; } - case(FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): { - result = createNonEmptyTmpDir(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return; - } - result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::info << "Directory removal attempt failed as expected" << std::endl; - } - else { - sif::warning << "Directory removal worked when it should not have!" << std::endl; - } - break; - } - case(FsOpCodes::RENAME_FILE): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl; - // Do not delete file, user can check existence in shell - fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); - fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg); - break; - } - case(FsOpCodes::APPEND_TO_FILE): { - // No mount prefix, cause file is created in tmp - cfg.useMountPrefix = false; - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - if(std::filesystem::exists("/tmp/test.txt")) { - fsHandler->removeDirectory("/tmp/", "test", false, &cfg); - } - sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl; - 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( - content.data()), content.size(), 0, &cfg); + case (FsOpCodes::RENAME_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl; + // Do not delete file, user can check existence in shell + fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg); + fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg); + break; } + case (FsOpCodes::APPEND_TO_FILE): { + // No mount prefix, cause file is created in tmp + cfg.useMountPrefix = false; + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + if (std::filesystem::exists("/tmp/test.txt")) { + fsHandler->removeDirectory("/tmp/", "test", false, &cfg); + } + sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl; + 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(content.data()), + content.size(), 0, &cfg); } + } } diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index 631c238a..b7aa791e 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -5,42 +5,42 @@ class CoreController; -class Q7STestTask: public TestTask { -public: - Q7STestTask(object_id_t objectId); +class Q7STestTask : public TestTask { + public: + Q7STestTask(object_id_t objectId); - ReturnValue_t initialize() override; -private: - bool doTestSdCard = false; - bool doTestScratchApi = false; - bool doTestGps = false; + ReturnValue_t initialize() override; - CoreController* coreController = nullptr; - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; + private: + bool doTestSdCard = false; + bool doTestScratchApi = false; + bool doTestGps = false; - void testGpsDaemon(); + CoreController* coreController = nullptr; + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; - void testSdCard(); - void fileTests(); + void testGpsDaemon(); - void testScratchApi(); - void testJsonLibDirect(); - void testDummyParams(); - void testProtHandler(); + void testSdCard(); + void fileTests(); - enum FsOpCodes { - CREATE_EMPTY_FILE_IN_TMP, - REMOVE_TMP_FILE, - CREATE_DIR_IN_TMP, - REMOVE_EMPTY_DIR_IN_TMP, - ATTEMPT_DIR_REMOVAL_NON_EMPTY, - REMOVE_FILLED_DIR_IN_TMP, - RENAME_FILE, - APPEND_TO_FILE, - }; - void testFileSystemHandlerDirect(FsOpCodes opCode); + void testScratchApi(); + void testJsonLibDirect(); + void testDummyParams(); + void testProtHandler(); + + enum FsOpCodes { + CREATE_EMPTY_FILE_IN_TMP, + REMOVE_TMP_FILE, + CREATE_DIR_IN_TMP, + REMOVE_EMPTY_DIR_IN_TMP, + ATTEMPT_DIR_REMOVAL_NON_EMPTY, + REMOVE_FILLED_DIR_IN_TMP, + RENAME_FILE, + APPEND_TO_FILE, + }; + void testFileSystemHandlerDirect(FsOpCodes opCode); }; - #endif /* BSP_Q7S_BOARDTEST_Q7STESTTASK_H_ */ diff --git a/bsp_q7s/callbacks/gnssCallback.cpp b/bsp_q7s/callbacks/gnssCallback.cpp index 479f4a2b..d5dbc3b0 100644 --- a/bsp_q7s/callbacks/gnssCallback.cpp +++ b/bsp_q7s/callbacks/gnssCallback.cpp @@ -1,26 +1,25 @@ #include "gnssCallback.h" -#include "devices/gpioIds.h" +#include "devices/gpioIds.h" #include "fsfw/tasks/TaskFactory.h" -ReturnValue_t gps::triggerGpioResetPin(void *args) { - ResetArgs* resetArgs = reinterpret_cast(args); - if(args == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - if (resetArgs->gpioComIF == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - gpioId_t gpioId; - if(resetArgs->gnss1) { - gpioId = gpioIds::GNSS_1_NRESET; +ReturnValue_t gps::triggerGpioResetPin(void* args) { + ResetArgs* resetArgs = reinterpret_cast(args); + if (args == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + if (resetArgs->gpioComIF == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + gpioId_t gpioId; + if (resetArgs->gnss1) { + gpioId = gpioIds::GNSS_1_NRESET; - } - else { - gpioId = gpioIds::GNSS_0_NRESET; - } - resetArgs->gpioComIF->pullLow(gpioId); - TaskFactory::delayTask(resetArgs->waitPeriodMs); - resetArgs->gpioComIF->pullHigh(gpioId); - return HasReturnvaluesIF::RETURN_OK; + } else { + gpioId = gpioIds::GNSS_0_NRESET; + } + resetArgs->gpioComIF->pullLow(gpioId); + TaskFactory::delayTask(resetArgs->waitPeriodMs); + resetArgs->gpioComIF->pullHigh(gpioId); + return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/callbacks/gnssCallback.h b/bsp_q7s/callbacks/gnssCallback.h index 9cbb6669..3e769899 100644 --- a/bsp_q7s/callbacks/gnssCallback.h +++ b/bsp_q7s/callbacks/gnssCallback.h @@ -1,13 +1,13 @@ #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; - LinuxLibgpioIF* gpioComIF = nullptr; - uint32_t waitPeriodMs = 100; + bool gnss1 = false; + LinuxLibgpioIF* gpioComIF = nullptr; + uint32_t waitPeriodMs = 100; }; namespace gps { diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 1e60e3c0..3ca3c181 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -1,238 +1,232 @@ #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 spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, + size_t sendLen, void* args) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + RwHandler* handler = reinterpret_cast(args); + if (handler == nullptr) { + sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } - RwHandler* handler = reinterpret_cast(args); - if(handler == nullptr) { - sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + uint8_t writeBuffer[2]; + uint8_t writeSize = 0; + + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF* gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if (mutex == nullptr or gpioIF == nullptr) { + sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + int fileDescriptor = 0; + std::string device = cookie->getSpiDevice(); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); + if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; + return SpiComIF::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie->getSpiParameters(spiMode, spiSpeed, nullptr); + comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; + return result; + } + + /** Sending frame start sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + if (gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; } + } - uint8_t writeBuffer[2]; - uint8_t writeSize = 0; + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } - gpioId_t gpioId = cookie->getChipSelectPin(); - GpioIF* gpioIF = comIf->getGpioInterface(); - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 0; - MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); - if(mutex == nullptr or gpioIF == nullptr) { - sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - - int fileDescriptor = 0; - std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); - if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; - return SpiComIF::OPENING_FILE_FAILED; + /** Encoding and sending command */ + size_t idx = 0; + while (idx < sendLen) { + switch (*(sendData + idx)) { + case 0x7E: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5E; + writeSize = 2; + break; + case 0x7D: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5D; + writeSize = 2; + break; + default: + writeBuffer[0] = *(sendData + idx); + writeSize = 1; + break; } - spi::SpiModes spiMode = spi::SpiModes::MODE_0; - uint32_t spiSpeed = 0; - cookie->getSpiParameters(spiMode, spiSpeed, nullptr); - comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - - result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; - return result; - } - - /** Sending frame start sign */ - writeBuffer[0] = 0x7E; - writeSize = 1; - - // Pull SPI CS low. For now, no support for active high given - if(gpioId != gpio::NO_GPIO) { - if(gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; - } - } - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } + idx++; + } + + /** Sending frame end sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_WRITE_FAILURE; + } + + uint8_t* rxBuf = nullptr; + result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); + if (result != HasReturnvaluesIF::RETURN_OK) { + closeSpi(gpioId, gpioIF, mutex); + return result; + } + + size_t replyBufferSize = cookie->getMaxBufferSize(); + + /** There must be a delay of at least 20 ms after sending the command */ + usleep(RwDefinitions::SPI_REPLY_DELAY); + + /** + * The reaction wheel responds with empty frames while preparing the reply data. + * However, receiving more than 5 empty frames will be interpreted as an error. + */ + uint8_t byteRead = 0; + for (int idx = 0; idx < 10; idx++) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_READ_FAILURE; + } + if (idx == 0) { + if (byteRead != FLAG_BYTE) { + sif::error << "Invalid data, expected start marker" << std::endl; closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; + return RwHandler::NO_START_MARKER; + } } - /** Encoding and sending command */ - size_t idx = 0; - while(idx < sendLen) { - switch(*(sendData + idx)) { - case 0x7E: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5E; - writeSize = 2; - break; - case 0x7D: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5D; - writeSize = 2; - break; - default: - writeBuffer[0] = *(sendData + idx); - writeSize = 1; - break; - } - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; - } - idx++; + if (byteRead != FLAG_BYTE) { + break; } - /** Sending frame end sign */ - writeBuffer[0] = 0x7E; - writeSize = 1; - - if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; - } - - uint8_t* rxBuf = nullptr; - result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); - if(result != HasReturnvaluesIF::RETURN_OK) { - closeSpi(gpioId, gpioIF, mutex); - return result; - } - - size_t replyBufferSize = cookie->getMaxBufferSize(); - - /** There must be a delay of at least 20 ms after sending the command */ - usleep(RwDefinitions::SPI_REPLY_DELAY); - - /** - * The reaction wheel responds with empty frames while preparing the reply data. - * However, receiving more than 5 empty frames will be interpreted as an error. - */ - uint8_t byteRead = 0; - for (int idx = 0; idx < 10; idx++) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::SPI_READ_FAILURE; - } - if(idx == 0) { - if(byteRead != FLAG_BYTE) { - sif::error << "Invalid data, expected start marker" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::NO_START_MARKER; - } - } - - if (byteRead != FLAG_BYTE) { - break; - } - - if (idx == 9) { - sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - return RwHandler::NO_REPLY; - } + if (idx == 9) { + sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::NO_REPLY; } + } #if FSFW_HAL_SPI_WIRETAPPING == 1 - sif::info << "RW start marker detected" << std::endl; + sif::info << "RW start marker detected" << std::endl; #endif - size_t decodedFrameLen = 0; - while(decodedFrameLen < replyBufferSize) { - - /** First byte already read in */ - if (decodedFrameLen != 0) { - byteRead = 0; - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - } - - if (byteRead == FLAG_BYTE) { - /** Reached end of frame */ - break; - } - else if (byteRead == 0x7D) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - if (byteRead == 0x5E) { - *(rxBuf + decodedFrameLen) = 0x7E; - decodedFrameLen++; - continue; - } - else if (byteRead == 0x5D) { - *(rxBuf + decodedFrameLen) = 0x7D; - decodedFrameLen++; - continue; - } - else { - sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; - closeSpi(gpioId, gpioIF, mutex); - result = RwHandler::INVALID_SUBSTITUTE; - break; - } - } - else { - *(rxBuf + decodedFrameLen) = byteRead; - decodedFrameLen++; - continue; - } - - /** - * There might be the unlikely case that each byte in a get-telemetry reply has been - * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. - * Otherwise there might be something wrong. - */ - if (decodedFrameLen == replyBufferSize) { - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; - result = RwHandler::SPI_READ_FAILURE; - break; - } - if (byteRead != 0x7E) { - sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; - decodedFrameLen--; - result = RwHandler::MISSING_END_SIGN; - break; - } - } - result = HasReturnvaluesIF::RETURN_OK; + size_t decodedFrameLen = 0; + while (decodedFrameLen < replyBufferSize) { + /** First byte already read in */ + if (decodedFrameLen != 0) { + byteRead = 0; + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } } - cookie->setTransferSize(decodedFrameLen); - - closeSpi(gpioId, gpioIF, mutex); - - return result; -} - -void closeSpi (gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "closeSpi: Failed to pull chip select high" << std::endl; - } + if (byteRead == FLAG_BYTE) { + /** Reached end of frame */ + break; + } else if (byteRead == 0x7D) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead == 0x5E) { + *(rxBuf + decodedFrameLen) = 0x7E; + decodedFrameLen++; + continue; + } else if (byteRead == 0x5D) { + *(rxBuf + decodedFrameLen) = 0x7D; + decodedFrameLen++; + continue; + } else { + sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + result = RwHandler::INVALID_SUBSTITUTE; + break; + } + } else { + *(rxBuf + decodedFrameLen) = byteRead; + decodedFrameLen++; + continue; } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl;; + + /** + * There might be the unlikely case that each byte in a get-telemetry reply has been + * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. + * Otherwise there might be something wrong. + */ + if (decodedFrameLen == replyBufferSize) { + if (read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead != 0x7E) { + sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; + decodedFrameLen--; + result = RwHandler::MISSING_END_SIGN; + break; + } } + result = HasReturnvaluesIF::RETURN_OK; + } + + cookie->setTransferSize(decodedFrameLen); + + closeSpi(gpioId, gpioIF, mutex); + + return result; } + +void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { + if (gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "closeSpi: Failed to pull chip select high" << std::endl; + } + } + if (mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl; + ; + } } +} // namespace rwSpiCallback diff --git a/bsp_q7s/callbacks/rwSpiCallback.h b/bsp_q7s/callbacks/rwSpiCallback.h index 8952f873..843d5b80 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.h +++ b/bsp_q7s/callbacks/rwSpiCallback.h @@ -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 { @@ -31,8 +30,8 @@ static constexpr uint8_t FLAG_BYTE = 0x7E; * To switch between the to SPI peripherals, an EMIO is used which will also be controlled * by this function. */ -ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, - size_t sendLen, void* args); +ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sendData, + size_t sendLen, void* args); /** * @brief This function closes a spi session. Pulls the chip select to high an releases the @@ -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_ */ diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 271ec508..bdbd51cc 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,1171 +1,1103 @@ #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 #include #include +#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) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - try { - result = initWatchdogFifo(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::CoreController: Watchdog FIFO init failed" << - std::endl; - } - sdcMan = SdCardManager::instance(); - if(sdcMan == nullptr) { - sif::error << "CoreController::CoreController: SD card manager invalid!" << std::endl; - } - - if(not BLOCKING_SD_INIT) { - sdcMan->setBlocking(false); - } - sdStateMachine(); - - result = initBootCopy(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; - } +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; } - catch(const std::filesystem::filesystem_error& e) { - sif::error << "CoreController::CoreController: Failed with exception " << - e.what() << std::endl; + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::error << "CoreController::CoreController: SD card manager invalid!" << std::endl; } + + if (not BLOCKING_SD_INIT) { + sdcMan->setBlocking(false); + } + sdStateMachine(); + + result = initBootCopy(); + 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; + } } ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { - return ExtendedControllerBase::handleCommandMessage(message); + return ExtendedControllerBase::handleCommandMessage(message); } void CoreController::performControlOperation() { - performWatchdogControlOperation(); - sdStateMachine(); + performWatchdogControlOperation(); + sdStateMachine(); } ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - return HasReturnvaluesIF::RETURN_OK; + LocalDataPoolManager &poolManager) { + 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; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - 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; - } + 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; + } - sdStateMachine(); - return ExtendedControllerBase::initialize(); + sdStateMachine(); + return ExtendedControllerBase::initialize(); } ReturnValue_t CoreController::initializeAfterTaskCreation() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(BLOCKING_SD_INIT) { - ReturnValue_t result = initSdCardBlocking(); - if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { - sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; - } + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (BLOCKING_SD_INIT) { + ReturnValue_t result = initSdCardBlocking(); + if (result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { + sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; } - sdStateMachine(); - result = initVersionFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; - } - // Add script folder to path - char* currentEnvPath = getenv("PATH"); - std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; - setenv("PATH", updatedEnvPath.c_str(), true); - updateProtInfo(); - initPrint(); - return result; + } + sdStateMachine(); + result = initVersionFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; + } + // Add script folder to path + char *currentEnvPath = getenv("PATH"); + std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; + setenv("PATH", updatedEnvPath.c_str(), true); + updateProtInfo(); + initPrint(); + return result; } ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } 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; - } + // 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; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE - sif::info << "No SD card initialization will be performed" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::info << "No SD card initialization will be performed" << std::endl; + return HasReturnvaluesIF::RETURN_OK; #else - result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Getting SD card activity status failed" << std::endl; - } + result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Getting SD card activity status failed" << std::endl; + } #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - determinePreferredSdCard(); - updateSdInfoOther(); - sif::info << "Cold redundant SD card configuration, preferred SD card: " << - static_cast(sdInfo.pref) << std::endl; - result = sdColdRedundantBlockingInit(); - // Update status file - sdcMan->updateSdCardStateFile(); - return result; + determinePreferredSdCard(); + updateSdInfoOther(); + sif::info << "Cold redundant SD card configuration, preferred SD card: " + << static_cast(sdInfo.pref) << std::endl; + result = sdColdRedundantBlockingInit(); + // Update status file + sdcMan->updateSdCardStateFile(); + return result; #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - sif::info << "Hot redundant SD card configuration" << std::endl; - sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false); - sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false); - // Update status file - sdcMan->updateSdCardStateFile(); - return HasReturnvaluesIF::RETURN_OK; + sif::info << "Hot redundant SD card configuration" << std::endl; + sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false); + sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false); + // Update status file + sdcMan->updateSdCardStateFile(); + return HasReturnvaluesIF::RETURN_OK; #endif #endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */ - } ReturnValue_t CoreController::sdStateMachine() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - SdCardManager::Operations operation; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + SdCardManager::Operations operation; - if(sdInfo.state == SdStates::IDLE) { - // Nothing to do - return result; - } + if (sdInfo.state == SdStates::IDLE) { + // Nothing to do + return result; + } - if(sdInfo.state == SdStates::START) { - // Init will be performed by separate function - if(BLOCKING_SD_INIT) { - sdInfo.state = SdStates::IDLE; - sdInfo.initFinished = true; - return result; - } - else { - // Still update SD state file + if (sdInfo.state == SdStates::START) { + // Init will be performed by separate function + if (BLOCKING_SD_INIT) { + sdInfo.state = SdStates::IDLE; + sdInfo.initFinished = true; + return result; + } else { + // Still update SD state file #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE - sdInfo.state = SdStates::UPDATE_INFO; + sdInfo.state = SdStates::UPDATE_INFO; #else - sdInfo.cycleCount = 0; - sdInfo.commandExecuted = false; - sdInfo.state = SdStates::GET_INFO; + sdInfo.cycleCount = 0; + sdInfo.commandExecuted = false; + sdInfo.state = SdStates::GET_INFO; #endif - } } + } - // 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) { - 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; - return false; - } - return false; - }; - - if(sdInfo.state == SdStates::GET_INFO) { - if(not sdInfo.commandExecuted) { - // Create update status file - result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } - sdInfo.commandExecuted = true; - } - else { - nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file"); - } + // 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) { + 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; + return false; } + return false; + }; - if(sdInfo.state == SdStates::SET_STATE_SELF) { - if(not sdInfo.commandExecuted) { - result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); - determinePreferredSdCard(); - updateSdInfoOther(); - if(sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { - sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; - sdInfo.pref = sd::SdCard::SLOT_0; - } - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Getting SD card activity status failed" << std::endl; - } + if (sdInfo.state == SdStates::GET_INFO) { + if (not sdInfo.commandExecuted) { + // Create update status file + result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" + << std::endl; + } + sdInfo.commandExecuted = true; + } else { + nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file"); + } + } + + if (sdInfo.state == SdStates::SET_STATE_SELF) { + if (not sdInfo.commandExecuted) { + result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); + determinePreferredSdCard(); + updateSdInfoOther(); + if (sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { + sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; + sdInfo.pref = sd::SdCard::SLOT_0; + } + if (result != HasReturnvaluesIF::RETURN_OK) { + 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(sdInfo.pref) << std::endl; + sif::info << "Cold redundant SD card configuration, preferred SD card: " + << static_cast(sdInfo.pref) << std::endl; #endif - if(sdInfo.prefState == sd::SdState::MOUNTED) { + 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 { - mountString = SdCardManager::SD_1_MOUNT_POINT; - } - sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " << - mountString << std::endl; + std::string mountString; + if (sdInfo.pref == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } + 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) { - sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar, false); - sdInfo.commandExecuted = true; - } - else if(sdInfo.prefState == sd::SdState::ON) { - sdInfo.state = SdStates::MOUNT_SELF; - } - } - else { - if(nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) { - sdInfo.prefState = sd::SdState::ON; - currentStateSetter(sdInfo.pref, sd::SdState::ON); - } - } + sdInfo.state = SdStates::DETERMINE_OTHER; + } 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) { + sdInfo.state = SdStates::MOUNT_SELF; + } + } else { + if (nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) { + sdInfo.prefState = sd::SdState::ON; + currentStateSetter(sdInfo.pref, sd::SdState::ON); + } } + } - if(sdInfo.state == SdStates::MOUNT_SELF) { - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { - sdInfo.prefState = sd::SdState::MOUNTED; - currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); - } - } + if (sdInfo.state == SdStates::MOUNT_SELF) { + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { + sdInfo.prefState = sd::SdState::MOUNTED; + currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); + } } + } - if(sdInfo.state == SdStates::DETERMINE_OTHER) { - // Determine whether any additional operations have to be done for the other SD card - // 1. Cold redundant case: Other SD card needs to be unmounted and switched off - // 2. Hot redundant case: Other SD card needs to be mounted and switched on + if (sdInfo.state == SdStates::DETERMINE_OTHER) { + // Determine whether any additional operations have to be done for the other SD card + // 1. Cold redundant case: Other SD card needs to be unmounted and switched off + // 2. Hot redundant case: Other SD card needs to be mounted and switched on #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) { - sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; - } - 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) { - sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; - } - else { - // Is already on and mounted, update info - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - } -#endif + if (sdInfo.otherState == sd::SdState::ON) { + sdInfo.state = SdStates::SET_STATE_OTHER; + } else if (sdInfo.otherState == sd::SdState::MOUNTED) { + sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; + } 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) { + sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; + } else { + // Is already on and mounted, update info + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; + } +#endif + } - if(sdInfo.state == SdStates::SET_STATE_OTHER) { - // Set state of other SD card to ON or OFF, depending on redundancy mode + if (sdInfo.state == SdStates::SET_STATE_OTHER) { + // Set state of other SD card to ON or OFF, depending on redundancy mode #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10, - "Switching off other SD card")) { - sdInfo.otherState = sd::SdState::OFF; - currentStateSetter(sdInfo.other, sd::SdState::OFF); - } - } -#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - 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")) { - sdInfo.otherState = sd::SdState::ON; - currentStateSetter(sdInfo.other, sd::SdState::ON); - } - } -#endif + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10, + "Switching off other SD card")) { + sdInfo.otherState = sd::SdState::OFF; + currentStateSetter(sdInfo.other, sd::SdState::OFF); + } } +#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT + 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")) { + sdInfo.otherState = sd::SdState::ON; + currentStateSetter(sdInfo.other, sd::SdState::ON); + } + } +#endif + } - if(sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) { - // Mount or unmount other SD card, depending on redundancy mode + if (sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) { + // Mount or unmount other SD card, depending on redundancy mode #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) { - sdInfo.otherState = sd::SdState::ON; - currentStateSetter(sdInfo.other, sd::SdState::ON); - } - } + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) { + sdInfo.otherState = sd::SdState::ON; + currentStateSetter(sdInfo.other, sd::SdState::ON); + } + } #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT - if(not sdInfo.commandExecuted) { - result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar); - sdInfo.commandExecuted = true; - } - else { - if(nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) { - sdInfo.otherState = sd::SdState::MOUNTED; - currentStateSetter(sdInfo.other, sd::SdState::MOUNTED); - } - } + if (not sdInfo.commandExecuted) { + result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar); + sdInfo.commandExecuted = true; + } else { + if (nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) { + sdInfo.otherState = sd::SdState::MOUNTED; + currentStateSetter(sdInfo.other, sd::SdState::MOUNTED); + } + } #endif - } + } - if(sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) { - sdInfo.state = SdStates::UPDATE_INFO; + if (sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) { + 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 + sdcMan->setBlocking(true); + // Update status file + result = sdcMan->updateSdCardStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; } - 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 - sdcMan->setBlocking(true); - // Update status file - result = sdcMan->updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Updating SD card state file failed" - << std::endl; - } - sdInfo.commandExecuted = false; - sdInfo.state = SdStates::IDLE; - sdInfo.cycleCount = 0; - sdcMan->setBlocking(false); - sdcMan->getSdCardActiveStatus(sdInfo.currentState); - if(not sdInfo.initFinished) { - updateSdInfoOther(); - sdInfo.initFinished = true; - sif::info << "SD card initialization finished" << std::endl; - } + sdInfo.commandExecuted = false; + sdInfo.state = SdStates::IDLE; + sdInfo.cycleCount = 0; + sdcMan->setBlocking(false); + sdcMan->getSdCardActiveStatus(sdInfo.currentState); + if (not sdInfo.initFinished) { + updateSdInfoOther(); + sdInfo.initFinished = true; + sif::info << "SD card initialization finished" << std::endl; } + } - if(sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) { - if(not sdInfo.commandExecuted) { - executeNextExternalSdCommand(); - } - else { - checkExternalSdCommandStatus(); - } + if (sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) { + if (not sdInfo.commandExecuted) { + executeNextExternalSdCommand(); + } else { + checkExternalSdCommandStatus(); } + } - sdInfo.cycleCount++; - return HasReturnvaluesIF::RETURN_OK; + sdInfo.cycleCount++; + return HasReturnvaluesIF::RETURN_OK; } void CoreController::executeNextExternalSdCommand() { - std::string sdChar; - sd::SdState currentStateOfCard = sd::SdState::OFF; - if(sdInfo.commandedCard == sd::SdCard::SLOT_0) { - sdChar = "0"; - currentStateOfCard = sdInfo.currentState.first; + std::string sdChar; + sd::SdState currentStateOfCard = sd::SdState::OFF; + if (sdInfo.commandedCard == sd::SdCard::SLOT_0) { + sdChar = "0"; + currentStateOfCard = sdInfo.currentState.first; + } 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) { + sdInfo.currentlyCommandedState = sd::SdState::ON; + } else { + // SD card is already on target state + sdInfo.commandFinished = true; + sdInfo.state = SdStates::IDLE; } - else { - sdChar = "1"; - currentStateOfCard = sdInfo.currentState.second; + } else if (currentStateOfCard == sd::SdState::ON) { + if (sdInfo.commandedState == sd::SdState::OFF or + sdInfo.commandedState == sd::SdState::MOUNTED) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else { + // Already on target state + sdInfo.commandFinished = true; + sdInfo.state = SdStates::IDLE; } - if(currentStateOfCard == sd::SdState::OFF) { - if(sdInfo.commandedState == sd::SdState::ON) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else if(sdInfo.commandedState == sd::SdState::MOUNTED) { - sdInfo.currentlyCommandedState = sd::SdState::ON; - } - else { - // SD card is already on target state - sdInfo.commandFinished = true; - sdInfo.state = SdStates::IDLE; - } + } else if (currentStateOfCard == sd::SdState::MOUNTED) { + if (sdInfo.commandedState == sd::SdState::ON) { + sdInfo.currentlyCommandedState = sdInfo.commandedState; + } else if (sdInfo.commandedState == sd::SdState::OFF) { + // This causes an unmount in sdCardSetup + sdInfo.currentlyCommandedState = sd::SdState::ON; + } else { + sdInfo.commandFinished = true; } - else if(currentStateOfCard == sd::SdState::ON) { - if(sdInfo.commandedState == sd::SdState::OFF or - sdInfo.commandedState == sd::SdState::MOUNTED) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else { - // Already on target state - sdInfo.commandFinished = true; - sdInfo.state = SdStates::IDLE; - } - } - else if(currentStateOfCard == sd::SdState::MOUNTED) { - if(sdInfo.commandedState == sd::SdState::ON) { - sdInfo.currentlyCommandedState = sdInfo.commandedState; - } - else if(sdInfo.commandedState == sd::SdState::OFF) { - // This causes an unmount in sdCardSetup - sdInfo.currentlyCommandedState = sd::SdState::ON; - } - else { - sdInfo.commandFinished = true; - } - } - sdCardSetup(sdInfo.commandedCard, sdInfo.commandedState, sdChar); - sdInfo.commandExecuted = true; + } + sdCardSetup(sdInfo.commandedCard, sdInfo.commandedState, sdChar); + sdInfo.commandExecuted = true; } void CoreController::checkExternalSdCommandStatus() { - SdCardManager::Operations operation; - SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); - if(status == SdCardManager::OpStatus::SUCCESS) { - if(sdInfo.currentlyCommandedState == sdInfo.commandedState) { - sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; - sdInfo.commandFinished = true; - } - 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) { - sif::warning << "CoreController::sdStateMachine: Commanding SD state " - "takes too long" << std::endl; + SdCardManager::Operations operation; + SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); + if (status == SdCardManager::OpStatus::SUCCESS) { + if (sdInfo.currentlyCommandedState == sdInfo.commandedState) { + sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; + sdInfo.commandFinished = true; + } 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) { + sif::warning << "CoreController::sdStateMachine: Commanding SD state " + "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 { - sdInfo.currentState.second = newState; - } + if (sdCard == sd::SdCard::SLOT_0) { + sdInfo.currentState.first = newState; + } else { + sdInfo.currentState.second = newState; + } } ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, - std::string sdChar, bool printOutput) { - std::string mountString; - sdcMan->setPrintCommandOutput(printOutput); - if(sdCard == sd::SdCard::SLOT_0) { - mountString = SdCardManager::SD_0_MOUNT_POINT; - } - else { - mountString = SdCardManager::SD_1_MOUNT_POINT; - } + std::string sdChar, bool printOutput) { + std::string mountString; + sdcMan->setPrintCommandOutput(printOutput); + if (sdCard == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } - sd::SdState state = sd::SdState::OFF; - if(sdCard == sd::SdCard::SLOT_0) { - state = sdInfo.currentState.first; - } - 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) { - sif::info << "Unmounting SD card " << sdChar << std::endl; - return sdcMan->unmountSdCard(sdCard); - } - else { - if(std::filesystem::exists(mountString)) { - 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; - return SdCardManager::MOUNT_ERROR; - } + sd::SdState state = sd::SdState::OFF; + if (sdCard == sd::SdCard::SLOT_0) { + state = sdInfo.currentState.first; + } 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) { + sif::info << "Unmounting SD card " << sdChar << std::endl; + return sdcMan->unmountSdCard(sdCard); + } else { + if (std::filesystem::exists(mountString)) { + 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; + 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; - return sdcMan->switchOnSdCard(sdCard, true, &sdInfo.currentState); - } - else if(targetState == sd::SdState::ON) { - sif::info << "Switching on SD card " << sdChar << std::endl; - return sdcMan->switchOnSdCard(sdCard, false, &sdInfo.currentState); - } + if (state == sd::SdState::OFF) { + if (targetState == sd::SdState::MOUNTED) { + 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) { + sif::info << "Switching on SD card " << sdChar << std::endl; + return sdcMan->switchOnSdCard(sdCard, false, &sdInfo.currentState); } + } - else if(state == sd::SdState::ON) { - 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) { - sif::info << "Switching off SD card " << sdChar << std::endl; - return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState); - } + else if (state == sd::SdState::ON) { + 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) { + sif::info << "Switching off SD card " << sdChar << std::endl; + return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState); } - else { - sif::warning << "CoreController::sdCardSetup: Invalid state for this call" << std::endl; - } - return HasReturnvaluesIF::RETURN_OK; + } 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) { - case(LIST_DIRECTORY_INTO_FILE): { - return actionListDirectoryIntoFile(actionId, commandedBy, data, size); + const uint8_t *data, size_t size) { + switch (actionId) { + case (LIST_DIRECTORY_INTO_FILE): { + return actionListDirectoryIntoFile(actionId, commandedBy, data, size); } - case(REBOOT_OBC): { - return actionPerformReboot(data, size); + case (REBOOT_OBC): { + return actionPerformReboot(data, size); } default: { - return HasActionsIF::INVALID_ACTION_ID; - } + return HasActionsIF::INVALID_ACTION_ID; } + } } ReturnValue_t CoreController::sdColdRedundantBlockingInit() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - 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; - // Try other SD card and mark set up operation as failed - sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); - result = HasReturnvaluesIF::RETURN_FAILED; - } + 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; + // Try other SD card and mark set up operation as failed + sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); + result = HasReturnvaluesIF::RETURN_FAILED; + } - if(result != HasReturnvaluesIF::RETURN_FAILED and sdInfo.otherState != sd::SdState::OFF) { - 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); - 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; - } + if (result != HasReturnvaluesIF::RETURN_FAILED and sdInfo.otherState != sd::SdState::OFF) { + 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); + 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; } - return result; + } + return result; } ReturnValue_t CoreController::incrementAllocationFailureCount() { - uint32_t count = 0; - ReturnValue_t result = scratch::readNumber(scratch::ALLOC_FAILURE_COUNT, count); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - count++; - return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count); + uint32_t count = 0; + ReturnValue_t result = scratch::readNumber(scratch::ALLOC_FAILURE_COUNT, count); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + count++; + return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count); } 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; + int result = std::system(unameCmd.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::versionFileInit"); + } + std::ifstream unameFile(unameFileName); + std::string unameLine; + if (not std::getline(unameFile, unameLine)) { + sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" << std::endl; + } - 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; - int result = std::system(unameCmd.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::versionFileInit"); - } - std::ifstream unameFile(unameFileName); - std::string unameLine; - if(not std::getline(unameFile, unameLine)) { - 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::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." + - 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; - std::fstream versionFile; - - if(not std::filesystem::exists(versionFilePath)) { - sif::info << "Writing version file " << versionFilePath << ".." << std::endl; - versionFile.open(versionFilePath, std::ios_base::out); - versionFile << fullObswVersionString << std::endl; - versionFile << fullFsfwVersionString << std::endl; - versionFile << systemString << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - - // Check whether any version has changed - bool createNewFile = false; - versionFile.open(versionFilePath); - std::string currentVersionString; - uint8_t idx = 0; - while(std::getline(versionFile, currentVersionString)) { - if(idx == 0) { - if(currentVersionString != fullObswVersionString) { - sif::info << "OBSW version changed" << std::endl; - sif::info << "From " << currentVersionString << " to " << - fullObswVersionString << std::endl; - createNewFile = true; - } - } - else if(idx == 1) { - if(currentVersionString != fullFsfwVersionString) { - sif::info << "FSFW version changed" << std::endl; - sif::info << "From " << currentVersionString << " to " << - fullFsfwVersionString << std::endl; - createNewFile = true; - } - } - 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 { - sif::warning << "Invalid version file! Rewriting it.." << std::endl; - createNewFile = true; - } - idx++; - } - - // Overwrite file if necessary - if(createNewFile) { - sif::info << "Rewriting version.txt file with updated versions.." << std::endl; - versionFile.close(); - versionFile.open(versionFilePath, std::ios_base::out | std::ios_base::trunc); - versionFile << fullObswVersionString << std::endl; - versionFile << fullFsfwVersionString << std::endl; - versionFile << systemString << std::endl; - } + std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + + 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::string systemString = "System: " + unameLine; + std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::string versionFilePath = mountPrefix + VERSION_FILE; + std::fstream versionFile; + if (not std::filesystem::exists(versionFilePath)) { + sif::info << "Writing version file " << versionFilePath << ".." << std::endl; + versionFile.open(versionFilePath, std::ios_base::out); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; return HasReturnvaluesIF::RETURN_OK; + } + + // Check whether any version has changed + bool createNewFile = false; + versionFile.open(versionFilePath); + std::string currentVersionString; + uint8_t idx = 0; + while (std::getline(versionFile, currentVersionString)) { + if (idx == 0) { + if (currentVersionString != fullObswVersionString) { + sif::info << "OBSW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << fullObswVersionString + << std::endl; + createNewFile = true; + } + } else if (idx == 1) { + if (currentVersionString != fullFsfwVersionString) { + sif::info << "FSFW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << fullFsfwVersionString + << std::endl; + createNewFile = true; + } + } 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 { + sif::warning << "Invalid version file! Rewriting it.." << std::endl; + createNewFile = true; + } + idx++; + } + + // Overwrite file if necessary + if (createNewFile) { + sif::info << "Rewriting version.txt file with updated versions.." << std::endl; + versionFile.close(); + versionFile.open(versionFilePath, std::ios_base::out | std::ios_base::trunc); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; + } + + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId, - 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 - // null termination. - if(size < 14) { - return HasActionsIF::INVALID_PARAMETERS; - } - // We could also make -l optional, but I can't think of a reason why to not use -l.. + 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 + // null termination. + if (size < 14) { + return HasActionsIF::INVALID_PARAMETERS; + } + // We could also make -l optional, but I can't think of a reason why to not use -l.. - // This flag specifies to run ls with -a - bool aFlag = data[0]; - data += 1; - // This flag specifies to run ls with -R - bool RFlag = data[1]; - data += 1; + // This flag specifies to run ls with -a + bool aFlag = data[0]; + data += 1; + // This flag specifies to run ls with -R + bool RFlag = data[1]; + data += 1; - size_t remainingSize = size - 2; - // One larger for null termination, which prevents undefined behaviour if the sent - // strings are not 0 terminated properly - std::vector repoAndTargetFileBuffer(remainingSize + 1, 0); - std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize); - const char* currentCharPtr = reinterpret_cast(repoAndTargetFileBuffer.data()); - // Full target file name - std::string repoName(currentCharPtr); - size_t repoLength = repoName.length(); - // The other string needs to be at least one letter plus NULL termination to be valid at all - // The first string also needs to be NULL terminated, but the termination is not included - // in the string length, so this is subtracted from the remaining size as well - if(repoLength > remainingSize - 3) { - return HasActionsIF::INVALID_PARAMETERS; - } - // The file length will not include the NULL termination, so we skip it - currentCharPtr += repoLength + 1; - std::string targetFileName(currentCharPtr); - std::ostringstream oss; - oss << "ls -l"; - if(aFlag) { - oss << "a"; - } - if(RFlag) { - oss << "R"; - } + size_t remainingSize = size - 2; + // One larger for null termination, which prevents undefined behaviour if the sent + // strings are not 0 terminated properly + std::vector repoAndTargetFileBuffer(remainingSize + 1, 0); + std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize); + const char *currentCharPtr = reinterpret_cast(repoAndTargetFileBuffer.data()); + // Full target file name + std::string repoName(currentCharPtr); + size_t repoLength = repoName.length(); + // The other string needs to be at least one letter plus NULL termination to be valid at all + // The first string also needs to be NULL terminated, but the termination is not included + // in the string length, so this is subtracted from the remaining size as well + if (repoLength > remainingSize - 3) { + return HasActionsIF::INVALID_PARAMETERS; + } + // The file length will not include the NULL termination, so we skip it + currentCharPtr += repoLength + 1; + std::string targetFileName(currentCharPtr); + std::ostringstream oss; + oss << "ls -l"; + if (aFlag) { + oss << "a"; + } + if (RFlag) { + oss << "R"; + } - oss << " " << repoName << " > " << targetFileName; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile"); - actionHelper.finish(false, commandedBy, actionId); - } - return HasReturnvaluesIF::RETURN_OK; + oss << " " << repoName << " > " << targetFileName; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile"); + actionHelper.finish(false, commandedBy, actionId); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::initBootCopy() { - if(not std::filesystem::exists(CURR_COPY_FILE)) { - // Thils file is created by the systemd service eive-early-config so this should - // not happen normally - std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); - int result = std::system(cmd.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::initBootCopy"); - } + if (not std::filesystem::exists(CURR_COPY_FILE)) { + // Thils file is created by the systemd service eive-early-config so this should + // not happen normally + std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); + int result = std::system(cmd.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::initBootCopy"); } - std::ifstream file(CURR_COPY_FILE); - std::string line; - std::getline(file, line); - std::istringstream iss(line); - int value = 0; - iss >> value; - CURRENT_CHIP = static_cast(value); - iss >> value; - CURRENT_COPY = static_cast(value); - return HasReturnvaluesIF::RETURN_OK; + } + std::ifstream file(CURR_COPY_FILE); + std::string line; + std::getline(file, line); + std::istringstream iss(line); + int value = 0; + iss >> value; + CURRENT_CHIP = static_cast(value); + iss >> value; + CURRENT_COPY = static_cast(value); + return HasReturnvaluesIF::RETURN_OK; } void CoreController::getCurrentBootCopy(Chip &chip, Copy ©) { - // Not really thread-safe but it does not need to be - chip = CURRENT_CHIP; - copy = CURRENT_COPY; + // Not really thread-safe but it does not need to be + chip = CURRENT_CHIP; + copy = CURRENT_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; - return HasReturnvaluesIF::RETURN_OK; - } - // Open FIFO write only and non-blocking to prevent SW from killing itself. - watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); - if(watchdogFifoFd < 0) { - 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; - return HasReturnvaluesIF::RETURN_FAILED; - } - } + 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; return HasReturnvaluesIF::RETURN_OK; + } + // Open FIFO write only and non-blocking to prevent SW from killing itself. + watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); + if (watchdogFifoFd < 0) { + 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; + return HasReturnvaluesIF::RETURN_FAILED; + } + } + return HasReturnvaluesIF::RETURN_OK; } void CoreController::initPrint() { #if OBSW_VERBOSE_LEVEL >= 1 - if(watchdogFifoFd > 0) { - sif::info << "Opened watchdog FIFO successfully.." << std::endl; - } + if (watchdogFifoFd > 0) { + sif::info << "Opened watchdog FIFO successfully.." << std::endl; + } #endif } ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t size) { - if(size < 1) { - return HasActionsIF::INVALID_PARAMETERS; - } - bool rebootSameBootCopy = data[0]; - bool protOpPerformed; - if(rebootSameBootCopy) { + if (size < 1) { + return HasActionsIF::INVALID_PARAMETERS; + } + bool rebootSameBootCopy = data[0]; + bool protOpPerformed; + if (rebootSameBootCopy) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl; + sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl; #endif - // Attempt graceful shutdown by unmounting and switching off SD cards - 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); - if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { - sif::info << "Running slot was writeprotected before reboot" << std::endl; - } - int result = std::system("xsc_boot_copy -r"); - if(result != 0) { - utility::handleSystemError(result, "CoreController::executeAction"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasActionsIF::EXECUTION_FINISHED; + // Attempt graceful shutdown by unmounting and switching off SD cards + 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); + if (retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { + sif::info << "Running slot was writeprotected before reboot" << std::endl; } - if(size < 3) { - return HasActionsIF::INVALID_PARAMETERS; - } -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "CoreController::actionPerformReboot: Rebooting on " << - static_cast(data[1]) << " " << static_cast(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(data[1]), - static_cast(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]); - int result = std::system(cmdString.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::executeAction"); - return HasReturnvaluesIF::RETURN_FAILED; + int result = std::system("xsc_boot_copy -r"); + if (result != 0) { + utility::handleSystemError(result, "CoreController::executeAction"); + return HasReturnvaluesIF::RETURN_FAILED; } return HasActionsIF::EXECUTION_FINISHED; + } + if (size < 3) { + return HasActionsIF::INVALID_PARAMETERS; + } +#if OBSW_VERBOSE_LEVEL >= 1 + sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast(data[1]) + << " " << static_cast(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(data[1]), static_cast(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]); + int result = std::system(cmdString.c_str()); + if (result != 0) { + utility::handleSystemError(result, "CoreController::executeAction"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasActionsIF::EXECUTION_FINISHED; } -CoreController::~CoreController() { -} +CoreController::~CoreController() {} void CoreController::determinePreferredSdCard() { - if(sdInfo.pref == sd::SdCard::NONE) { - ReturnValue_t result = sdcMan->getPreferredSdCard(sdInfo.pref); - 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; - sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); - sdInfo.pref = sd::SdCard::SLOT_0; - } - else { - sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" - "information from the scratch buffer" << std::endl; - } - } + if (sdInfo.pref == sd::SdCard::NONE) { + ReturnValue_t result = sdcMan->getPreferredSdCard(sdInfo.pref); + 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; + sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); + sdInfo.pref = sd::SdCard::SLOT_0; + } else { + sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" + "information from the scratch buffer" + << std::endl; + } } + } } void CoreController::updateSdInfoOther() { - if(sdInfo.pref == sd::SdCard::SLOT_0) { - sdInfo.prefChar = "0"; - sdInfo.otherChar = "1"; - sdInfo.otherState = sdInfo.currentState.second; - sdInfo.prefState = sdInfo.currentState.first; - sdInfo.other = sd::SdCard::SLOT_1; + if (sdInfo.pref == sd::SdCard::SLOT_0) { + sdInfo.prefChar = "0"; + sdInfo.otherChar = "1"; + sdInfo.otherState = sdInfo.currentState.second; + sdInfo.prefState = sdInfo.currentState.first; + sdInfo.other = 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 { - sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; - } + } 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 { + 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); - if(result != 0) { - utility::handleSystemError(result, "CoreController::generateChipStateFile"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + int result = std::system(CHIP_PROT_SCRIPT); + if (result != 0) { + utility::handleSystemError(result, "CoreController::generateChipStateFile"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, - bool protect, bool& protOperationPerformed, bool updateProtFile) { - bool allChips = false; - bool allCopies = false; - bool selfChip = false; - bool selfCopy = false; - protOperationPerformed = false; +ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect, + bool &protOperationPerformed, + bool updateProtFile) { + bool allChips = false; + bool allCopies = false; + bool selfChip = false; + bool selfCopy = false; + protOperationPerformed = false; - switch(targetChip) { - case(Chip::ALL_CHIP): { - allChips = true; - break; + switch (targetChip) { + case (Chip::ALL_CHIP): { + allChips = true; + break; } - case(Chip::NO_CHIP): { - return HasReturnvaluesIF::RETURN_OK; + case (Chip::NO_CHIP): { + return HasReturnvaluesIF::RETURN_OK; } - case(Chip::SELF_CHIP): { - selfChip = true; - targetChip = CURRENT_CHIP; - break; + case (Chip::SELF_CHIP): { + selfChip = true; + targetChip = CURRENT_CHIP; + break; } default: { - break; + break; } + } + switch (targetCopy) { + case (Copy::ALL_COPY): { + allCopies = true; + break; } - switch(targetCopy) { - case(Copy::ALL_COPY): { - allCopies = true; - break; + case (Copy::NO_COPY): { + return HasReturnvaluesIF::RETURN_OK; } - case(Copy::NO_COPY): { - return HasReturnvaluesIF::RETURN_OK; - } - case(Copy::SELF_COPY): { - selfCopy = true; - targetCopy = CURRENT_COPY; - break; + case (Copy::SELF_COPY): { + selfCopy = true; + targetCopy = CURRENT_COPY; + break; } default: { - break; - } + break; } + } - for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { - int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, - protOperationPerformed, selfChip, selfCopy, allChips, allCopies, arrIdx); - if(result != 0) { - break; - } + for (uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { + int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, protOperationPerformed, + selfChip, selfCopy, allChips, allCopies, arrIdx); + if (result != 0) { + break; } - if(protOperationPerformed and updateProtFile) { - updateProtInfo(); - } - return HasReturnvaluesIF::RETURN_OK; + } + if (protOperationPerformed and updateProtFile) { + updateProtInfo(); + } + return HasReturnvaluesIF::RETURN_OK; } int CoreController::handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, - bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips, - bool allCopies, uint8_t arrIdx) { - bool currentProt = protArray[arrIdx]; - std::ostringstream oss; - bool performOp = false; - if(protect == currentProt) { - return 0; - } - if(protOperationPerformed) { - if((selfChip and selfCopy) or (not allCopies and not allChips)) { - // No need to continue, only one operation was requested - return 1; - } - } - Chip currentChip; - Copy currentCopy; - oss << "writeprotect "; - if(arrIdx == 0 or arrIdx == 1) { - oss << "0 "; - currentChip = Chip::CHIP_0; - } - else { - oss << "1 "; - currentChip = Chip::CHIP_1; - } - if(arrIdx == 0 or arrIdx == 2) { - oss << "0 "; - currentCopy = Copy::COPY_0; - } - else { - oss << "1 "; - currentCopy = Copy::COPY_1; - } - if(protect) { - oss << "1"; - } - else { - oss << "0"; - } - - int result = 0; - if(allChips and allCopies) { - performOp = true; - } - 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)) { - performOp = true; - } - } - else if(selfChip and (currentChip == targetChip)) { - if(selfCopy) { - if(currentCopy == targetCopy) { - performOp = true; - } - } - else { - performOp = true; - } - - } - else if(selfCopy and (currentCopy == targetCopy)) { - if(selfChip) { - if(currentChip == targetChip) { - performOp = true; - } - } - else { - performOp = true; - } - } - else if((targetChip == currentChip) and (targetCopy == currentCopy)) { - performOp = true; - } - if(result != 0) { - utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); - } - if(performOp) { - // TODO: Lock operation take a long time. Use command executor? That would require a - // new state machine.. - protOperationPerformed = true; - sif::info << "Executing command: " << oss.str() << std::endl; - result = std::system(oss.str().c_str()); - } + bool &protOperationPerformed, bool selfChip, + bool selfCopy, bool allChips, bool allCopies, + uint8_t arrIdx) { + bool currentProt = protArray[arrIdx]; + std::ostringstream oss; + bool performOp = false; + if (protect == currentProt) { return 0; + } + if (protOperationPerformed) { + if ((selfChip and selfCopy) or (not allCopies and not allChips)) { + // No need to continue, only one operation was requested + return 1; + } + } + Chip currentChip; + Copy currentCopy; + oss << "writeprotect "; + if (arrIdx == 0 or arrIdx == 1) { + oss << "0 "; + currentChip = Chip::CHIP_0; + } else { + oss << "1 "; + currentChip = Chip::CHIP_1; + } + if (arrIdx == 0 or arrIdx == 2) { + oss << "0 "; + currentCopy = Copy::COPY_0; + } else { + oss << "1 "; + currentCopy = Copy::COPY_1; + } + if (protect) { + oss << "1"; + } else { + oss << "0"; + } + + int result = 0; + if (allChips and allCopies) { + performOp = true; + } 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)) { + performOp = true; + } + } else if (selfChip and (currentChip == targetChip)) { + if (selfCopy) { + if (currentCopy == targetCopy) { + performOp = true; + } + } else { + performOp = true; + } + + } else if (selfCopy and (currentCopy == targetCopy)) { + if (selfChip) { + if (currentChip == targetChip) { + performOp = true; + } + } else { + performOp = true; + } + } else if ((targetChip == currentChip) and (targetCopy == currentCopy)) { + performOp = true; + } + if (result != 0) { + utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); + } + if (performOp) { + // TODO: Lock operation take a long time. Use command executor? That would require a + // new state machine.. + protOperationPerformed = true; + sif::info << "Executing command: " << oss.str() << std::endl; + result = std::system(oss.str().c_str()); + } + return 0; } ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) { - using namespace std; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(regenerateChipStateFile) { - result = generateChipStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" << - std::endl; - return result; - } + using namespace std; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (regenerateChipStateFile) { + result = generateChipStateFile(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" + << std::endl; + return result; } - if(not filesystem::exists(CHIP_STATE_FILE)) { - return HasReturnvaluesIF::RETURN_FAILED; + } + if (not filesystem::exists(CHIP_STATE_FILE)) { + return HasReturnvaluesIF::RETURN_FAILED; + } + ifstream chipStateFile(CHIP_STATE_FILE); + if (not chipStateFile.good()) { + return HasReturnvaluesIF::RETURN_FAILED; + } + string nextLine; + uint8_t lineCounter = 0; + string word; + while (getline(chipStateFile, nextLine)) { + ReturnValue_t result = handleProtInfoUpdateLine(nextLine); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Protection info update failed!" << std::endl; + return result; } - ifstream chipStateFile(CHIP_STATE_FILE); - if(not chipStateFile.good()) { - return HasReturnvaluesIF::RETURN_FAILED; + ++lineCounter; + if (lineCounter > 4) { + sif::warning << "CoreController::checkAndProtectBootCopy: " + "Line counter larger than 4" + << std::endl; } - string nextLine; - uint8_t lineCounter = 0; - string word; - while(getline(chipStateFile, nextLine)) { - ReturnValue_t result = handleProtInfoUpdateLine(nextLine); - if(result != HasReturnvaluesIF::RETURN_OK) { - 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; - } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { - using namespace std; - string word; - uint8_t wordIdx = 0; - uint8_t arrayIdx = 0; - istringstream iss(nextLine); - Chip currentChip = Chip::CHIP_0; - Copy currentCopy = Copy::COPY_0; - while(iss >> word) { - if(wordIdx == 1) { - currentChip = static_cast(stoi(word)); - } - if(wordIdx == 3) { - currentCopy = static_cast(stoi(word)); - } - - if(wordIdx == 3) { - if(currentChip == Chip::CHIP_0) { - if(currentCopy == Copy::COPY_0) { - arrayIdx = 0; - } - else if(currentCopy == Copy::COPY_1) { - arrayIdx = 1; - } - } - - else if(currentChip == Chip::CHIP_1) { - if(currentCopy == Copy::COPY_0) { - arrayIdx = 2; - } - else if(currentCopy == Copy::COPY_1) { - arrayIdx = 3; - } - } - } - if(wordIdx == 5) { - if(word == "unlocked.") { - protArray[arrayIdx] = false; - } - else { - protArray[arrayIdx] = true; - } - } - wordIdx++; + using namespace std; + string word; + uint8_t wordIdx = 0; + uint8_t arrayIdx = 0; + istringstream iss(nextLine); + Chip currentChip = Chip::CHIP_0; + Copy currentCopy = Copy::COPY_0; + while (iss >> word) { + if (wordIdx == 1) { + currentChip = static_cast(stoi(word)); } - return HasReturnvaluesIF::RETURN_OK; + if (wordIdx == 3) { + currentCopy = static_cast(stoi(word)); + } + + if (wordIdx == 3) { + if (currentChip == Chip::CHIP_0) { + if (currentCopy == Copy::COPY_0) { + arrayIdx = 0; + } else if (currentCopy == Copy::COPY_1) { + arrayIdx = 1; + } + } + + else if (currentChip == Chip::CHIP_1) { + if (currentCopy == Copy::COPY_0) { + arrayIdx = 2; + } else if (currentCopy == Copy::COPY_1) { + arrayIdx = 3; + } + } + } + if (wordIdx == 5) { + if (word == "unlocked.") { + protArray[arrayIdx] = false; + } else { + protArray[arrayIdx] = true; + } + } + wordIdx++; + } + return HasReturnvaluesIF::RETURN_OK; } void CoreController::performWatchdogControlOperation() { - // Only perform each fifth iteration - if(watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { - if(watchdogFifoFd == RETRY_FIFO_OPEN) { - // Open FIFO write only and non-blocking - watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); - if(watchdogFifoFd < 0) { - if(errno == ENXIO) { - 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; - return; - } - } - sif::info << "Opened " << watchdog::FIFO_NAME << " successfully" << std::endl; - } - 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; - } + // Only perform each fifth iteration + if (watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { + if (watchdogFifoFd == RETRY_FIFO_OPEN) { + // Open FIFO write only and non-blocking + watchdogFifoFd = open(watchdog::FIFO_NAME.c_str(), O_WRONLY | O_NONBLOCK); + if (watchdogFifoFd < 0) { + if (errno == ENXIO) { + 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; + return; } + } + sif::info << "Opened " << watchdog::FIFO_NAME << " successfully" << std::endl; + } 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; + } } - + } } diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 74702441..5365000a 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -2,183 +2,167 @@ #define BSP_Q7S_CORE_CORECONTROLLER_H_ #include -#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 - }; +class CoreController : public ExtendedControllerBase { + public: + 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"; - static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; - static constexpr char VERSION_FILE[] = "/conf/sd_status"; + 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"; + static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; + static constexpr char VERSION_FILE[] = "/conf/sd_status"; - static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; - static constexpr ActionId_t REBOOT_OBC = 32; - static constexpr ActionId_t MOUNT_OTHER_COPY = 33; + static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; + 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 uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; + static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); - static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + CoreController(object_id_t objectId); + virtual ~CoreController(); + ReturnValue_t initialize() override; - CoreController(object_id_t objectId); - virtual~ CoreController(); + ReturnValue_t initializeAfterTaskCreation() override; - ReturnValue_t initialize() override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; - ReturnValue_t initializeAfterTaskCreation() override; + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + void performControlOperation() override; - ReturnValue_t executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t *data, size_t size) override; + /** + * Generate a file containing the chip lock/unlock states inside /tmp/chip_prot_status.txt + * @return + */ + static ReturnValue_t generateChipStateFile(); + static ReturnValue_t incrementAllocationFailureCount(); + static void getCurrentBootCopy(Chip& chip, Copy& copy); - ReturnValue_t handleCommandMessage(CommandMessage *message) override; - void performControlOperation() override; + ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true); - /** - * Generate a file containing the chip lock/unlock states inside /tmp/chip_prot_status.txt - * @return - */ - static ReturnValue_t generateChipStateFile(); - static ReturnValue_t incrementAllocationFailureCount(); - static void getCurrentBootCopy(Chip& chip, Copy& copy); + /** + * Checks whether the target chip and copy are write protected and protect set them to a target + * state where applicable. + * @param targetChip + * @param targetCopy + * @param protect Target state + * @param protOperationPerformed [out] Can be used to determine whether any operation + * was performed + * @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 updateProtInfo(bool regenerateChipStateFile = true); + bool sdInitFinished() const; - /** - * Checks whether the target chip and copy are write protected and protect set them to a target - * state where applicable. - * @param targetChip - * @param targetCopy - * @param protect Target state - * @param protOperationPerformed [out] Can be used to determine whether any operation - * was performed - * @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); + private: + static Chip CURRENT_CHIP; + static Copy CURRENT_COPY; - bool sdInitFinished() const; + // Designated value for rechecking FIFO open + static constexpr int RETRY_FIFO_OPEN = -2; + int watchdogFifoFd = 0; -private: - static Chip CURRENT_CHIP; - static Copy CURRENT_COPY; + // States for SD state machine, which is used in non-blocking mode + enum class SdStates { + NONE, + START, + GET_INFO, + SET_STATE_SELF, + MOUNT_SELF, + // Determine operations for other SD card, depending on redundancy configuration + DETERMINE_OTHER, + SET_STATE_OTHER, + // Mount or unmount other + MOUNT_UNMOUNT_OTHER, + // Skip period because the shell command used to generate the info file sometimes is + // missing the last performed operation if executed too early + SKIP_CYCLE_BEFORE_INFO_UPDATE, + UPDATE_INFO, + // SD initialization done + IDLE, + // Used if SD switches or mount commands are issued via telecommand + SET_STATE_FROM_COMMAND, + }; + static constexpr bool BLOCKING_SD_INIT = false; - // Designated value for rechecking FIFO open - static constexpr int RETRY_FIFO_OPEN = -2; - int watchdogFifoFd = 0; + SdCardManager* sdcMan = nullptr; - // States for SD state machine, which is used in non-blocking mode - enum class SdStates { - NONE, - START, - GET_INFO, - SET_STATE_SELF, - MOUNT_SELF, - // Determine operations for other SD card, depending on redundancy configuration - DETERMINE_OTHER, - SET_STATE_OTHER, - // Mount or unmount other - MOUNT_UNMOUNT_OTHER, - // Skip period because the shell command used to generate the info file sometimes is - // missing the last performed operation if executed too early - SKIP_CYCLE_BEFORE_INFO_UPDATE, - UPDATE_INFO, - // SD initialization done - IDLE, - // Used if SD switches or mount commands are issued via telecommand - SET_STATE_FROM_COMMAND, - }; - static constexpr bool BLOCKING_SD_INIT = false; + struct SdInfo { + sd::SdCard pref = sd::SdCard::NONE; + sd::SdState prefState = sd::SdState::OFF; + sd::SdCard other = sd::SdCard::NONE; + sd::SdState otherState = sd::SdState::OFF; + std::string prefChar = "0"; + std::string otherChar = "1"; + SdStates state = SdStates::START; + // Used to track whether a command was executed + bool commandExecuted = true; + bool initFinished = false; + SdCardManager::SdStatePair currentState; + uint16_t cycleCount = 0; + // These two flags are related to external commanding + bool commandIssued = false; + bool commandFinished = false; + sd::SdState currentlyCommandedState = sd::SdState::OFF; + sd::SdCard commandedCard = sd::SdCard::NONE; + sd::SdState commandedState = sd::SdState::OFF; + }; + SdInfo sdInfo; - SdCardManager* sdcMan = nullptr; + /** + * Index 0: Chip 0 Copy 0 + * Index 1: Chip 0 Copy 1 + * Index 2: Chip 1 Copy 0 + * Index 3: Chip 1 Copy 1 + */ + std::array protArray; + PeriodicOperationDivider opDivider; - struct SdInfo { - sd::SdCard pref = sd::SdCard::NONE; - sd::SdState prefState = sd::SdState::OFF; - sd::SdCard other = sd::SdCard::NONE; - sd::SdState otherState = sd::SdState::OFF; - std::string prefChar = "0"; - std::string otherChar = "1"; - SdStates state = SdStates::START; - // Used to track whether a command was executed - bool commandExecuted = true; - bool initFinished = false; - SdCardManager::SdStatePair currentState; - uint16_t cycleCount = 0; - // These two flags are related to external commanding - bool commandIssued = false; - bool commandFinished = false; - sd::SdState currentlyCommandedState = sd::SdState::OFF; - sd::SdCard commandedCard = sd::SdCard::NONE; - sd::SdState commandedState = sd::SdState::OFF; - }; - SdInfo sdInfo; + 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); - /** - * Index 0: Chip 0 Copy 0 - * Index 1: Chip 0 Copy 1 - * Index 2: Chip 1 Copy 0 - * Index 3: Chip 1 Copy 1 - */ - std::array protArray; - PeriodicOperationDivider opDivider; + ReturnValue_t initVersionFile(); + ReturnValue_t initBootCopy(); + ReturnValue_t initWatchdogFifo(); + ReturnValue_t initSdCardBlocking(); + void initPrint(); - 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 sdStateMachine(); + void updateSdInfoOther(); + ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar, + bool printOutput = true); + ReturnValue_t sdColdRedundantBlockingInit(); + void currentStateSetter(sd::SdCard sdCard, sd::SdState newState); + void determinePreferredSdCard(); + void executeNextExternalSdCommand(); + void checkExternalSdCommandStatus(); - ReturnValue_t initVersionFile(); - ReturnValue_t initBootCopy(); - ReturnValue_t initWatchdogFifo(); - ReturnValue_t initSdCardBlocking(); - void initPrint(); + ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + ReturnValue_t actionPerformReboot(const uint8_t* data, size_t size); - ReturnValue_t sdStateMachine(); - void updateSdInfoOther(); - ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar, - bool printOutput = true); - ReturnValue_t sdColdRedundantBlockingInit(); - void currentStateSetter(sd::SdCard sdCard, sd::SdState newState); - void determinePreferredSdCard(); - void executeNextExternalSdCommand(); - void checkExternalSdCommandStatus(); + void performWatchdogControlOperation(); - ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t *data, size_t size); - ReturnValue_t actionPerformReboot(const uint8_t *data, size_t size); - - void performWatchdogControlOperation(); - - 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); + 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); }; #endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */ diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index df857d59..dce7f27e 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -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 #include +#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"); @@ -30,344 +29,343 @@ ServiceInterfaceStream sif::warning("WARNING", true); ServiceInterfaceStream sif::error("ERROR", true, false, true); #endif -ObjectManagerIF *objectManager = nullptr; +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); + sif::info << "Initializing all objects.." << std::endl; + ObjectManager::instance()->initialize(); - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ - ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr); - sif::info << "Initializing all objects.." << std::endl; - ObjectManager::instance()->initialize(); - - /* This function creates and starts all tasks */ - initTasks(); + /* This function creates and starts all tasks */ + initTasks(); } void initmission::initTasks() { - TaskFactory* factory = TaskFactory::instance(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(factory == nullptr) { - /* Should never happen ! */ - return; - } + TaskFactory* factory = TaskFactory::instance(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (factory == nullptr) { + /* Should never happen ! */ + return; + } #if OBSW_PRINT_MISSED_DEADLINES == 1 - void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; + void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline; #else - void (*missedDeadlineFunc) (void) = nullptr; + void (*missedDeadlineFunc)(void) = nullptr; #endif #if BOARD_TE0720 == 0 - PeriodicTaskIF* coreController = factory->createPeriodicTask( - "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); - result = coreController->addComponent(objects::CORE_CONTROLLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); - } + PeriodicTaskIF* coreController = factory->createPeriodicTask( + "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = coreController->addComponent(objects::CORE_CONTROLLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); + } #endif - /* TMTC Distribution */ - PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( - "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR); - } - result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR); - } - result = tmTcDistributor->addComponent(objects::TM_FUNNEL); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); - } + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR); + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_PACKET_DISTRIB", objects::PUS_PACKET_DISTRIBUTOR); + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); + } #if OBSW_ADD_TCPIP_BRIDGE == 1 - // TMTC bridge - PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); - } - PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); - } + // TMTC bridge + PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( + "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); + } + PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( + "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); + } #endif #if OBSW_USE_CCSDS_IP_CORE == 1 - PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( - "CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); - } + PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( + "CCSDS_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); + } - // Minimal distance between two received TCs amounts to 0.6 seconds - // If a command has not been read before the next one arrives, the old command will be - // overwritten by the PDEC. - PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( - "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); - result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); - } + // Minimal distance between two received TCs amounts to 0.6 seconds + // If a command has not been read before the next one arrives, the old command will be + // overwritten by the PDEC. + PeriodicTaskIF* pdecHandlerTask = factory->createPeriodicTask( + "PDEC_HANDLER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); + result = pdecHandlerTask->addComponent(objects::PDEC_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PDEC Handler", objects::PDEC_HANDLER); + } #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ - PeriodicTaskIF* acsCtrl = factory->createPeriodicTask( - "ACS_CTRL", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); - result = acsCtrl->addComponent(objects::GPS_CONTROLLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("ACS_CTRL", objects::GPS_CONTROLLER); - } + PeriodicTaskIF* acsCtrl = factory->createPeriodicTask( + "ACS_CTRL", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = acsCtrl->addComponent(objects::GPS_CONTROLLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("ACS_CTRL", objects::GPS_CONTROLLER); + } -# if BOARD_TE0720 == 0 - // FS task, task interval does not matter because it runs in permanent loop, priority low - // because it is a non-essential background task - PeriodicTaskIF* fsTask = factory->createPeriodicTask( - "FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); - result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); - } +#if BOARD_TE0720 == 0 + // FS task, task interval does not matter because it runs in permanent loop, priority low + // because it is a non-essential background task + PeriodicTaskIF* fsTask = factory->createPeriodicTask( + "FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); + } #if OBSW_ADD_STAR_TRACKER == 1 - PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( - "FILE_SYSTEM_TASK", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = strImgLoaderTask->addComponent(objects::STR_HELPER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::STR_HELPER); - } + PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( + "FILE_SYSTEM_TASK", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = strImgLoaderTask->addComponent(objects::STR_HELPER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::STR_HELPER); + } #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* BOARD_TE0720 */ #if OBSW_TEST_CCSDS_BRIDGE == 1 - PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( - "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE); - } + PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( + "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE); + } #endif - std::vector pusTasks; - createPusTasks(*factory, missedDeadlineFunc, pusTasks); - std::vector pstTasks; - createPstTasks(*factory, missedDeadlineFunc, pstTasks); + std::vector pusTasks; + createPusTasks(*factory, missedDeadlineFunc, pusTasks); + std::vector pstTasks; + createPstTasks(*factory, missedDeadlineFunc, pstTasks); #if OBSW_ADD_TEST_CODE == 1 - std::vector testTasks; - createTestTasks(*factory, missedDeadlineFunc, testTasks); + std::vector testTasks; + createTestTasks(*factory, missedDeadlineFunc, testTasks); #endif - auto taskStarter = [](std::vector& taskVector, std::string name) { - for(const auto& task: taskVector) { - if(task != nullptr) { - task->startTask(); - } - else { - sif::error << "Task in vector " << name << " is invalid!" << std::endl; - } - } - }; + auto taskStarter = [](std::vector& taskVector, std::string name) { + for (const auto& task : taskVector) { + if (task != nullptr) { + task->startTask(); + } else { + sif::error << "Task in vector " << name << " is invalid!" << std::endl; + } + } + }; - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); #if OBSW_ADD_TCPIP_BRIDGE == 1 - tmtcBridgeTask->startTask(); - tmtcPollingTask->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); #endif #if OBSW_USE_CCSDS_IP_CORE == 1 - ccsdsHandlerTask->startTask(); - pdecHandlerTask->startTask(); + ccsdsHandlerTask->startTask(); + pdecHandlerTask->startTask(); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ #if BOARD_TE0720 == 0 - coreController->startTask(); + coreController->startTask(); #endif - taskStarter(pstTasks, "PST task vector"); - taskStarter(pusTasks, "PUS task vector"); + taskStarter(pstTasks, "PST task vector"); + taskStarter(pusTasks, "PUS task vector"); #if OBSW_ADD_TEST_CODE == 1 - taskStarter(testTasks, "Test task vector"); + taskStarter(testTasks, "Test task vector"); #endif #if OBSW_TEST_CCSDS_BRIDGE == 1 - ptmeTestTask->startTask(); + ptmeTestTask->startTask(); #endif #if BOARD_TE0720 == 0 - fsTask->startTask(); + fsTask->startTask(); #if OBSW_ADD_STAR_TRACKER == 1 - strImgLoaderTask->startTask(); + strImgLoaderTask->startTask(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif - acsCtrl->startTask(); + acsCtrl->startTask(); - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } void initmission::createPstTasks(TaskFactory& factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #if BOARD_TE0720 == 0 - /* Polling Sequence Table Default */ + /* 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); - 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 { - taskVec.push_back(spiPst); + FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( + "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 { + taskVec.push_back(spiPst); + } #endif - FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( - "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstUart(uartPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(uartPst); - FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask( - "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstGpio(gpioPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } - taskVec.push_back(gpioPst); - FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( - "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); - result = pst::pstI2c(i2cPst); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; - } + FixedTimeslotTaskIF* uartPst = factory.createFixedTimeslotTask( + "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstUart(uartPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(uartPst); + FixedTimeslotTaskIF* gpioPst = factory.createFixedTimeslotTask( + "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstGpio(gpioPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + taskVec.push_back(gpioPst); + FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask( + "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc); + result = pst::pstI2c(i2cPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } - FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask( - "GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); - result = pst::pstGompaceCan(gomSpacePstTask); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; - } - taskVec.push_back(gomSpacePstTask); -#else /* BOARD_TE7020 == 0 */ - FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( - "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; - } - taskVec.push_back(pollingSequenceTaskTE0720); + FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask( + "GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); + result = pst::pstGompaceCan(gomSpacePstTask); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; + } + taskVec.push_back(gomSpacePstTask); +#else /* BOARD_TE7020 == 0 */ + FixedTimeslotTaskIF* pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( + "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; + } + taskVec.push_back(pollingSequenceTaskTE0720); #endif /* BOARD_TE7020 == 1 */ } -void initmission::createPusTasks(TaskFactory &factory, - TaskDeadlineMissedFunction missedDeadlineFunc, std::vector &taskVec) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - /* PUS Services */ - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); - } - taskVec.push_back(pusVerification); +void initmission::createPusTasks(TaskFactory& factory, + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + /* PUS Services */ + PeriodicTaskIF* pusVerification = factory.createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); + } + taskVec.push_back(pusVerification); - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); - } - result = pusEvents->addComponent(objects::EVENT_MANAGER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); - } - taskVec.push_back(pusEvents); + PeriodicTaskIF* pusEvents = factory.createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); + } + result = pusEvents->addComponent(objects::EVENT_MANAGER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); + } + taskVec.push_back(pusEvents); - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } - result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); - } - taskVec.push_back(pusHighPrio); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); + } + taskVec.push_back(pusHighPrio); - PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( - "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT); - } - result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS); - } - taskVec.push_back(pusMedPrio); + PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Object add component failed" << std::endl; + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_20", objects::PUS_SERVICE_20_PARAMETERS); + } + taskVec.push_back(pusMedPrio); - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); - } - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); + PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); + } + result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); + } + taskVec.push_back(pusLowPrio); } -void initmission::createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec) { -#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; +void initmission::createTestTasks(TaskFactory& factory, + TaskDeadlineMissedFunction missedDeadlineFunc, + std::vector& taskVec) { +#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( - "TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); + PeriodicTaskIF* testTask = factory.createPeriodicTask( + "TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); #if OBSW_ADD_TEST_TASK == 1 - result = testTask->addComponent(objects::TEST_TASK); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); - } + result = testTask->addComponent(objects::TEST_TASK); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } #endif /* OBSW_ADD_TEST_TASK == 1 */ #if OBSW_ADD_SPI_TEST_CODE == 1 - result = testTask->addComponent(objects::SPI_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); - } + result = testTask->addComponent(objects::SPI_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); + } #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 - result = testTask->addComponent(objects::LIBGPIOD_TEST); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); - } + result = testTask->addComponent(objects::LIBGPIOD_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); + } #endif /* BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 */ - taskVec.push_back(testTask); + taskVec.push_back(testTask); } diff --git a/bsp_q7s/core/InitMission.h b/bsp_q7s/core/InitMission.h index ffdfc11c..5c509b79 100644 --- a/bsp_q7s/core/InitMission.h +++ b/bsp_q7s/core/InitMission.h @@ -1,9 +1,10 @@ #ifndef BSP_Q7S_INITMISSION_H_ #define BSP_Q7S_INITMISSION_H_ -#include "fsfw/tasks/Typedef.h" #include +#include "fsfw/tasks/Typedef.h" + class PeriodicTaskIF; class TaskFactory; @@ -12,11 +13,11 @@ void initMission(); void initTasks(); void createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); + std::vector& taskVec); void createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); + std::vector& taskVec); void createTestTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, - std::vector& taskVec); -}; + std::vector& taskVec); +}; // namespace initmission #endif /* BSP_Q7S_INITMISSION_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 7b111c4f..4c57ab34 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,87 +1,82 @@ -#include #include "ObjectFactory.h" -#include "bsp_q7s/devices/startracker/StrHelper.h" -#include "bsp_q7s/devices/startracker/StarTrackerDefinitions.h" +#include + #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 -#include #include +#include +#include #include #include #include @@ -89,1015 +84,1015 @@ ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; -void ObjectFactory::setStatics() { - Factory::setStaticFrameworkObjectIds(); -} +void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); } void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; - PusServiceBase::packetDestination = objects::TM_FUNNEL; + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; - CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; - CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; - //DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; - DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; + // DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; + DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; #if OBSW_TM_TO_PTME == 1 - TmFunnel::downlinkDestination = objects::CCSDS_HANDLER; + TmFunnel::downlinkDestination = objects::CCSDS_HANDLER; #else - TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; + TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; #endif /* OBSW_TM_TO_PTME == 1 */ - // No storage object for now. - TmFunnel::storageDestination = objects::NO_OBJECT; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; - LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; + LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - TmPacketBase::timeStamperId = objects::TIME_STAMPER; + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketBase::timeStamperId = objects::TIME_STAMPER; } void ObjectFactory::produce(void* args) { - ObjectFactory::setStatics(); - ObjectFactory::produceGenericObjects(); + ObjectFactory::setStatics(); + ObjectFactory::produceGenericObjects(); - LinuxLibgpioIF* gpioComIF = nullptr; - UartComIF* uartComIF = nullptr; - SpiComIF* spiComIF = nullptr; - createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiComIF); - createTmpComponents(); + LinuxLibgpioIF* gpioComIF = nullptr; + UartComIF* uartComIF = nullptr; + SpiComIF* spiComIF = nullptr; + createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiComIF); + createTmpComponents(); #if BOARD_TE0720 == 0 - new CoreController(objects::CORE_CONTROLLER); + new CoreController(objects::CORE_CONTROLLER); - createPcduComponents(); - createRadSensorComponent(gpioComIF); - createSunSensorComponents(gpioComIF, spiComIF); + createPcduComponents(); + createRadSensorComponent(gpioComIF); + createSunSensorComponents(gpioComIF, spiComIF); #if OBSW_ADD_ACS_BOARD == 1 - createAcsBoardComponents(gpioComIF, uartComIF); + createAcsBoardComponents(gpioComIF, uartComIF); #endif /* OBSW_ADD_ACS_BOARD == 1 */ - createHeaterComponents(); - createSolarArrayDeploymentComponents(); + createHeaterComponents(); + createSolarArrayDeploymentComponents(); #if OBSW_ADD_SYRLINKS == 1 - createSyrlinksComponents(); + createSyrlinksComponents(); #endif /* OBSW_ADD_SYRLINKS == 1 */ #if OBSW_ADD_RTD_DEVICES == 1 - createRtdComponents(gpioComIF); + createRtdComponents(gpioComIF); #endif /* OBSW_ADD_RTD_DEVICES == 1 */ - 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); + 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); - new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); + 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); - plocSupervisorCookie->setNoFixedSizeReply(); - PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( - objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); - plocSupervisor->setStartUpImmediately(); + 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); + plocSupervisor->setStartUpImmediately(); #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ - new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); + 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); - starTrackerCookie->setNoFixedSizeReply(); - StrHelper* strHelper = new StrHelper(objects::STR_HELPER); - StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(objects::STAR_TRACKER, - objects::UART_COM_IF, starTrackerCookie, strHelper); - starTrackerHandler->setStartUpImmediately(); + 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->setStartUpImmediately(); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif /* TE7020 == 0 */ #if OBSW_USE_CCSDS_IP_CORE == 1 - createCcsdsComponents(gpioComIF); + createCcsdsComponents(gpioComIF); #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ - /* Test Task */ + /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 - createTestComponents(gpioComIF); + createTestComponents(gpioComIF); #endif /* OBSW_ADD_TEST_CODE == 1 */ - new PlocUpdater(objects::PLOC_UPDATER); - new PlocMemoryDumper(objects::PLOC_MEMORY_DUMPER); + new PlocUpdater(objects::PLOC_UPDATER); + new PlocMemoryDumper(objects::PLOC_MEMORY_DUMPER); } 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); - (void) tmp1075Handler_1; - Tmp1075Handler* tmp1075Handler_2 = new Tmp1075Handler(objects::TMP1075_HANDLER_2, - objects::I2C_COM_IF, i2cCookieTmp1075tcs2); - (void) tmp1075Handler_2; + /* Temperature sensors */ + 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); + (void)tmp1075Handler_2; } -void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF, UartComIF** uartComIF, - SpiComIF** spiComIF) { - if (gpioComIF == nullptr or uartComIF == nullptr or spiComIF == nullptr) { - sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" - << std::endl; - } - *gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF); +void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, + SpiComIF** spiComIF) { + if (gpioComIF == nullptr or uartComIF == nullptr or spiComIF == nullptr) { + sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" + << std::endl; + } + *gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF); - /* Communication interfaces */ - new CspComIF(objects::CSP_COM_IF); - new I2cComIF(objects::I2C_COM_IF); - *uartComIF = new UartComIF(objects::UART_COM_IF); + /* Communication interfaces */ + new CspComIF(objects::CSP_COM_IF); + new I2cComIF(objects::I2C_COM_IF); + *uartComIF = new UartComIF(objects::UART_COM_IF); #if OBSW_ADD_SPI_TEST_CODE == 0 - *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); + *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); #endif /* Q7S_ADD_SPI_TEST_CODE == 0 */ #if BOARD_TE0720 == 0 - /* Adding gpios for chip select decoding to the gpioComIf */ - gpioCallbacks::initSpiCsDecoder(*gpioComIF); + /* Adding gpios for chip select decoding to the gpioComIf */ + gpioCallbacks::initSpiCsDecoder(*gpioComIF); #endif } void ObjectFactory::createPcduComponents() { - CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, addresses::P60DOCK); - CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU1); - 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); - new PCDUHandler(objects::PCDU_HANDLER, 50); + CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, addresses::P60DOCK); + CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU1); + 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); + new PCDUHandler(objects::PCDU_HANDLER, 50); - /** - * Setting PCDU devices to mode normal immediately after start up because PCDU is always - * running. - */ - p60dockhandler->setModeNormal(); - pdu1handler->setModeNormal(); - pdu2handler->setModeNormal(); - acuhandler->setModeNormal(); + /** + * Setting PCDU devices to mode normal immediately after start up because PCDU is always + * running. + */ + p60dockhandler->setModeNormal(); + pdu1handler->setModeNormal(); + pdu2handler->setModeNormal(); + acuhandler->setModeNormal(); } void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { - GpioCookie* gpioCookieRadSensor = new GpioCookie; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::RAD_SENSOR; - GpiodRegularByLineName* gpio = new GpiodRegularByLineName( - q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); - gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, gpio); - gpioComIF->addGpios(gpioCookieRadSensor); + GpioCookie* gpioCookieRadSensor = new GpioCookie; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::RAD_SENSOR; + GpiodRegularByLineName* gpio = new GpiodRegularByLineName( + q7s::gpioNames::RAD_SENSOR_CHIP_SELECT, consumer.str(), gpio::DIR_OUT, gpio::HIGH); + 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); - new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); + 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); } -void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF, SpiComIF* spiComIF) { - GpioCookie* gpioCookieSus = new GpioCookie(); - GpioCallback* susgpio = nullptr; +void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF) { + GpioCookie* gpioCookieSus = new GpioCookie(); + GpioCallback* susgpio = nullptr; - susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); - susgpio = new GpioCallback("Chip select SUS 2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); - susgpio = new GpioCallback("Chip select SUS 3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); - susgpio = new GpioCallback("Chip select SUS 4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); - susgpio = new GpioCallback("Chip select SUS 5", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); - susgpio = new GpioCallback("Chip select SUS 6", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); - susgpio = new GpioCallback("Chip select SUS 7", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); - susgpio = new GpioCallback("Chip select SUS 8", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); - susgpio = new GpioCallback("Chip select SUS 9", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); - susgpio = new GpioCallback("Chip select SUS 10", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); - susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); - susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); - susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); + susgpio = new GpioCallback("Chip select SUS 1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); + susgpio = new GpioCallback("Chip select SUS 2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); + susgpio = new GpioCallback("Chip select SUS 3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); + susgpio = new GpioCallback("Chip select SUS 4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); + susgpio = new GpioCallback("Chip select SUS 5", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); + susgpio = new GpioCallback("Chip select SUS 6", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); + susgpio = new GpioCallback("Chip select SUS 7", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); + susgpio = new GpioCallback("Chip select SUS 8", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); + susgpio = new GpioCallback("Chip select SUS 9", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); + susgpio = new GpioCallback("Chip select SUS 10", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); + susgpio = new GpioCallback("Chip select SUS 11", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); + susgpio = new GpioCallback("Chip select SUS 12", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); + susgpio = new GpioCallback("Chip select SUS 13", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); - gpioComIF->addGpios(gpioCookieSus); + 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_10, objects::SPI_COM_IF, spiCookieSus10, gpioComIF, - gpioIds::CS_SUS_10); - new SusHandler(objects::SUS_11, objects::SPI_COM_IF, spiCookieSus11, gpioComIF, - gpioIds::CS_SUS_11); - new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, - gpioIds::CS_SUS_12); - new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, - gpioIds::CS_SUS_13); + 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, + gpioIds::CS_SUS_11); + new SusHandler(objects::SUS_12, objects::SPI_COM_IF, spiCookieSus12, gpioComIF, + gpioIds::CS_SUS_12); + new SusHandler(objects::SUS_13, objects::SPI_COM_IF, spiCookieSus13, gpioComIF, + gpioIds::CS_SUS_13); } -void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComIF* uartComIF) { - GpioCookie* gpioCookieAcsBoard = new GpioCookie(); +void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF) { + GpioCookie* gpioCookieAcsBoard = new GpioCookie(); - 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); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + 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); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_1_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_1_L3G_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ADIS_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_3_L3G_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_3_L3G_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_0_LIS3_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_0_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_1_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_1_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - 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); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + 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); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::MGM_3_RM3100_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::MGM_3_CS, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - // GNSS reset pins are active low - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + // GNSS reset pins are active low + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, - gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, + gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); - 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); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + 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); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GYRO_2_ADIS_HANDLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_2_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); - // 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); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); + // 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); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::GPS_CONTROLLER; - gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; + gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); - gpioComIF->addGpios(gpioCookieAcsBoard); + gpioComIF->addGpios(gpioCookieAcsBoard); - std::string spiDev = q7s::SPI_DEFAULT_DEV; - 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); - mgmLis3Handler->setStartUpImmediately(); + std::string spiDev = q7s::SPI_DEFAULT_DEV; + 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); + mgmLis3Handler->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler->setToGoToNormalMode(true); + mgmLis3Handler->setToGoToNormalMode(true); #endif - 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); - mgmRm3100Handler->setStartUpImmediately(); + 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); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - 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); - mgmLis3Handler2->setStartUpImmediately(); + 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); + mgmLis3Handler2->setStartUpImmediately(); #if FSFW_HAL_LIS3MDL_MGM_DEBUG == 1 - mgmLis3Handler2->setToGoToNormalMode(true); + mgmLis3Handler2->setToGoToNormalMode(true); #endif - 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); - mgmRm3100Handler->setStartUpImmediately(); + 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); + mgmRm3100Handler->setStartUpImmediately(); #if FSFW_HAL_RM3100_MGM_DEBUG == 1 - mgmRm3100Handler->setToGoToNormalMode(true); + mgmRm3100Handler->setToGoToNormalMode(true); #endif - // Commented until ACS board V2 in in clean room again - // Gyro 0 Side A - spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, - ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, - spi::DEFAULT_ADIS16507_SPEED); - auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, - 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); - auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::L3G_TRANSITION_DELAY); - gyroL3gHandler->setStartUpImmediately(); + // Commented until ACS board V2 in in clean room again + // Gyro 0 Side A + spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED); + auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, + 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); + auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::L3G_TRANSITION_DELAY); + gyroL3gHandler->setStartUpImmediately(); #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - gyroL3gHandler->setToGoToNormalMode(true); + gyroL3gHandler->setToGoToNormalMode(true); #endif - // Gyro 2 Side B - spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, - ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, - spi::DEFAULT_ADIS16507_SPEED); - adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, - 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); - gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, - spiCookie, spi::L3G_TRANSITION_DELAY); - gyroL3gHandler->setStartUpImmediately(); + // Gyro 2 Side B + spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, + ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, + spi::DEFAULT_ADIS16507_SPEED); + adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_COM_IF, + 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); + gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, objects::SPI_COM_IF, + spiCookie, spi::L3G_TRANSITION_DELAY); + gyroL3gHandler->setStartUpImmediately(); #if FSFW_HAL_L3GD20_GYRO_DEBUG == 1 - gyroL3gHandler->setToGoToNormalMode(true); + gyroL3gHandler->setToGoToNormalMode(true); #endif - bool debugGps = false; + bool debugGps = false; #if OBSW_DEBUG_GPS == 1 - debugGps = true; + debugGps = true; #endif - resetArgsGnss1.gnss1 = true; - resetArgsGnss1.gpioComIF = gpioComIF; - resetArgsGnss1.waitPeriodMs = 100; - resetArgsGnss0.gnss1 = false; - resetArgsGnss0.gpioComIF = gpioComIF; - resetArgsGnss0.waitPeriodMs = 100; - auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, - debugGps); - gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); + resetArgsGnss1.gnss1 = true; + resetArgsGnss1.gpioComIF = gpioComIF; + resetArgsGnss1.waitPeriodMs = 100; + resetArgsGnss0.gnss1 = false; + resetArgsGnss0.gpioComIF = gpioComIF; + resetArgsGnss0.waitPeriodMs = 100; + 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; - GpioCookie* heaterGpiosCookie = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::HEATER_HANDLER; + /* Pin H2-11 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); + /* Pin H2-12 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); - std::stringstream consumer; - consumer << "0x" << std::hex << objects::HEATER_HANDLER; - /* Pin H2-11 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_0, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpio); - /* Pin H2-12 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpio); + /* Pin H2-13 on stack connector */ + gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); - /* Pin H2-13 on stack connector */ - gpio = new GpiodRegularByLineName(q7s::gpioNames::HEATER_2, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpio); + 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_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); + heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpio); - 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); + heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpio); - 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); + heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpio); - 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); + heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpio); - 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, - objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); + new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, + objects::PCDU_HANDLER, pcduSwitches::TCS_BOARD_8V_HEATER_IN); } void ObjectFactory::createSolarArrayDeploymentComponents() { - GpioCookie* solarArrayDeplCookie = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; + GpioCookie* solarArrayDeplCookie = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; - 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); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); + 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); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::SA_DPL_PIN_1, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpio); - //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); + // 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); } 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); - syrlinksUartCookie->setParityEven(); + 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); + new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); } -void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { - GpioCookie* rtdGpioCookie = new GpioCookie; +void ObjectFactory::createRtdComponents(LinuxLibgpioIF* gpioComIF) { + GpioCookie* rtdGpioCookie = new GpioCookie; - GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); - GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); - GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); - GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); - GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); - GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); - GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); - GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); - GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); - GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); - GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); - GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); - GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); - GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); - GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); - GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); + GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0); + GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1); + GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2); + GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3); + GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4); + GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5); + GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6); + GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7); + GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8); + GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9); + GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10); + GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11); + GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12); + GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13); + GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14); + GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15); - gpioComIF->addGpios(rtdGpioCookie); + gpioComIF->addGpios(rtdGpioCookie); - 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, - 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, - 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, - 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, - 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, - 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, - 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* 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, + 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, + 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, + 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, + 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, + 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, + 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(); - rtdIc2->setStartUpImmediately(); + rtdIc0->setStartUpImmediately(); + rtdIc1->setStartUpImmediately(); + rtdIc2->setStartUpImmediately(); #if OBSW_DEBUG_RTD == 1 - rtdIc0->setInstantNormal(true); - rtdIc1->setInstantNormal(true); - rtdIc2->setInstantNormal(true); + rtdIc0->setInstantNormal(true); + rtdIc1->setInstantNormal(true); + rtdIc2->setInstantNormal(true); #endif - static_cast(rtdIc0); - static_cast(rtdIc1); - static_cast(rtdIc2); - static_cast(rtdIc3); - static_cast(rtdIc4); - static_cast(rtdIc5); - static_cast(rtdIc6); - static_cast(rtdIc7); - static_cast(rtdIc8); - static_cast(rtdIc9); - static_cast(rtdIc10); - static_cast(rtdIc11); - static_cast(rtdIc12); - static_cast(rtdIc13); - static_cast(rtdIc14); - static_cast(rtdIc15); + static_cast(rtdIc0); + static_cast(rtdIc1); + static_cast(rtdIc2); + static_cast(rtdIc3); + static_cast(rtdIc4); + static_cast(rtdIc5); + static_cast(rtdIc6); + static_cast(rtdIc7); + static_cast(rtdIc8); + static_cast(rtdIc9); + static_cast(rtdIc10); + static_cast(rtdIc11); + static_cast(rtdIc12); + static_cast(rtdIc13); + static_cast(rtdIc14); + static_cast(rtdIc15); } void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { - GpioCookie* gpioCookieRw = new GpioCookie; - GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); - GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); - GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); - GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::DIR_OUT, gpio::HIGH, - &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); + GpioCookie* gpioCookieRw = new GpioCookie; + GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); + GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); + GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); + GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::DIR_OUT, gpio::HIGH, + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); - 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); - 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); - 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); - 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); - gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); + 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); + 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); + 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); + 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); + gpioCookieRw->addGpio(gpioIds::EN_RW4, gpio); - gpioComIF->addGpios(gpioCookieRw); + 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(); + rwHandler1->setStartUpImmediately(); #endif - rw1SpiCookie->setCallbackArgs(rwHandler1); + 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(); + rwHandler2->setStartUpImmediately(); #endif - rw2SpiCookie->setCallbackArgs(rwHandler2); + 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(); + rwHandler3->setStartUpImmediately(); #endif - rw3SpiCookie->setCallbackArgs(rwHandler3); + 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(); + rwHandler4->setStartUpImmediately(); #endif - rw4SpiCookie->setCallbackArgs(rwHandler4); + rw4SpiCookie->setCallbackArgs(rwHandler4); } -void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { - // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core - GpioCookie* gpioCookiePtmeIp = new GpioCookie; - GpiodRegularByLineName* gpio = nullptr; - std::stringstream consumer; - consumer << "0x" << std::hex << objects::PAPB_VC0; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC0, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_BUSY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC0; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC0, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_EMPTY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC1; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC1, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_BUSY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC1; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC1, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC2; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC2, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_BUSY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC2; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC2, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_EMPTY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC3; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC3, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_BUSY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC3; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); - gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); +void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { + // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core + GpioCookie* gpioCookiePtmeIp = new GpioCookie; + GpiodRegularByLineName* gpio = nullptr; + std::stringstream consumer; + consumer << "0x" << std::hex << objects::PAPB_VC0; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC0, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_BUSY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC0; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC0, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_EMPTY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC1; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC1, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_BUSY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC1; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC1, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC2; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC2, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_BUSY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC2; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC2, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_EMPTY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC3; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC3, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_BUSY, gpio); + consumer.str(""); + consumer << "0x" << std::hex << objects::PAPB_VC3; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); + gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); - gpioComIF->addGpios(gpioCookiePtmeIp); + gpioComIF->addGpios(gpioCookiePtmeIp); - // Creating virtual channel interfaces - VcInterfaceIF* vc0 = new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, - gpioIds::VC0_PAPB_EMPTY, PtmeConfig::VC0_OFFSETT); - VcInterfaceIF* vc1 = new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, - gpioIds::VC1_PAPB_EMPTY, PtmeConfig::VC1_OFFSETT); - VcInterfaceIF* vc2 = new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, - gpioIds::VC2_PAPB_EMPTY, PtmeConfig::VC2_OFFSETT); - VcInterfaceIF* vc3 = new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, - gpioIds::VC3_PAPB_EMPTY, PtmeConfig::VC3_OFFSETT); + // Creating virtual channel interfaces + VcInterfaceIF* vc0 = new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, + gpioIds::VC0_PAPB_EMPTY, PtmeConfig::VC0_OFFSETT); + VcInterfaceIF* vc1 = new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, + gpioIds::VC1_PAPB_EMPTY, PtmeConfig::VC1_OFFSETT); + VcInterfaceIF* vc2 = new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, + gpioIds::VC2_PAPB_EMPTY, PtmeConfig::VC2_OFFSETT); + VcInterfaceIF* vc3 = new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, + gpioIds::VC3_PAPB_EMPTY, PtmeConfig::VC3_OFFSETT); - // Creating ptme object and adding virtual channel interfaces - Ptme* ptme = new Ptme(objects::PTME); - ptme->addVcInterface(ccsds::VC0, vc0); - ptme->addVcInterface(ccsds::VC1, vc1); - ptme->addVcInterface(ccsds::VC2, vc2); - ptme->addVcInterface(ccsds::VC3, vc3); + // Creating ptme object and adding virtual channel interfaces + Ptme* ptme = new Ptme(objects::PTME); + ptme->addVcInterface(ccsds::VC0, vc0); + ptme->addVcInterface(ccsds::VC1, vc1); + ptme->addVcInterface(ccsds::VC2, vc2); + ptme->addVcInterface(ccsds::VC3, vc3); - GpioCookie* gpioCookieRateSetter = new GpioCookie; - consumer.str(""); - consumer << "ptme rate setter"; - // Init to low -> default bit rate is low bit rate (200 kbps in downlink with syrlinks) - gpio = new GpiodRegularByLineName(q7s::gpioNames::BIT_RATE_SEL, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRateSetter->addGpio(gpioIds::BIT_RATE_SEL, gpio); - gpioComIF->addGpios(gpioCookieRateSetter); + GpioCookie* gpioCookieRateSetter = new GpioCookie; + consumer.str(""); + consumer << "ptme rate setter"; + // Init to low -> default bit rate is low bit rate (200 kbps in downlink with syrlinks) + gpio = new GpiodRegularByLineName(q7s::gpioNames::BIT_RATE_SEL, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookieRateSetter->addGpio(gpioIds::BIT_RATE_SEL, gpio); + gpioComIF->addGpios(gpioCookieRateSetter); - TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(gpioIds::BIT_RATE_SEL, 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); - ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); - vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); - vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); - vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); - ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); + VirtualChannel* vc = nullptr; + vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); + vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); + vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); + vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE); + ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); - GpioCookie* gpioCookiePdec = new GpioCookie; - consumer.str(""); - consumer << "0x" << std::hex << objects::PDEC_HANDLER; - // GPIO also low after linux boot (specified by device-tree) - gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); + GpioCookie* gpioCookiePdec = new GpioCookie; + consumer.str(""); + consumer << "0x" << std::hex << objects::PDEC_HANDLER; + // GPIO also low after linux boot (specified by device-tree) + gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), gpio::DIR_OUT, + gpio::LOW); + gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio); - gpioComIF->addGpios(gpioCookiePdec); + gpioComIF->addGpios(gpioCookiePdec); - new PdecHandler(objects::PDEC_HANDLER, objects::CCSDS_HANDLER, gpioComIF, gpioIds::PDEC_RESET, - std::string(q7s::UIO_PDEC_CONFIG_MEMORY), std::string(q7s::UIO_PDEC_RAM), - std::string(q7s::UIO_PDEC_REGISTERS)); + new PdecHandler(objects::PDEC_HANDLER, objects::CCSDS_HANDLER, gpioComIF, gpioIds::PDEC_RESET, + std::string(q7s::UIO_PDEC_CONFIG_MEMORY), std::string(q7s::UIO_PDEC_RAM), + std::string(q7s::UIO_PDEC_REGISTERS)); #if BOARD_TE0720 == 0 - GpioCookie* gpioRS485Chip = new GpioCookie; - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); + GpioCookie* gpioRS485Chip = new GpioCookie; + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio); - // Default configuration enables RX channels (RXEN = LOW) - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", - gpio::Direction::DIR_OUT, gpio::LOW); - gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); + // Default configuration enables RX channels (RXEN = LOW) + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver", + gpio::Direction::DIR_OUT, gpio::LOW); + gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio); - gpioComIF->addGpios(gpioRS485Chip); + gpioComIF->addGpios(gpioRS485Chip); #endif /* BOARD_TE0720 == 0 */ } void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { - #if BOARD_TE0720 == 0 - new Q7STestTask(objects::TEST_TASK); + new Q7STestTask(objects::TEST_TASK); #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 #if OBSW_TEST_GPIO_OPEN_BYLABEL == 1 - /* Configure MIO0 as input */ - GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::DIR_OUT, 0, "/amba_pl/gpio@41200000", 0); + /* 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); + /* Configure MIO0 as input */ + GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); #endif /* OBSW_TEST_GPIO_LABEL == 1 */ - GpioCookie* gpioCookie = new GpioCookie; - gpioCookie->addGpio(gpioIds::TEST_ID_0, testGpio); - new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); + GpioCookie* gpioCookie = new GpioCookie; + gpioCookie->addGpio(gpioIds::TEST_ID_0, testGpio); + new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); #endif #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); - gpioCookieSus->addGpio(gpioIds::CS_SUS_1, chipSelectSus); - gpioComIF->addGpios(gpioCookieSus); + GpioCookie* gpioCookieSus = new GpioCookie; + 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")); - gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); - GpiodRegular* papbEmpty = new GpiodRegular(std::string("gpiochip0"), 1, - std::string("PAPBEmpty_VC0")); - gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); - gpioComIF->addGpios(gpioCookieCcsdsIp); + GpioCookie* gpioCookieCcsdsIp = new GpioCookie; + 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")); + gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_EMPTY, papbEmpty); + gpioComIF->addGpios(gpioCookieCcsdsIp); - new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, - objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), - gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); + new CCSDSIPCoreBridge(objects::CCSDS_IP_CORE_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR, + objects::TM_STORE, objects::TC_STORE, gpioComIF, std::string("/dev/uio0"), + gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); #endif #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); - gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); - gpioComIF->addGpios(gpioCookieRadSensor); + GpioCookie* gpioCookieRadSensor = new GpioCookie; + 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); - radSensor->setStartUpImmediately(); + 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); - /* Testing PlocMPSoCHandler on TE0720-03-1CFA */ - PlocMPSoCHandler* mpsocPlocHandler = new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, - plocUartCookie); - mpsocPlocHandler->setStartUpImmediately(); + 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); + 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); - GpioCookie* gpioCookie = new GpioCookie; - gpioCookie->addGpio(gpioIds::HEATER_0, heaterGpio); - new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, gpioCookie, objects::PCDU_HANDLER, - pcduSwitches::TCS_BOARD_8V_HEATER_IN); + /* Configuration for MIO0 on TE0720-03-1CFA */ + 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, + pcduSwitches::TCS_BOARD_8V_HEATER_IN); #endif #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); - plocSupervisorCookie->setNoFixedSizeReply(); - PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( - objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); - plocSupervisor->setStartUpImmediately(); + /* 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); + plocSupervisorCookie->setNoFixedSizeReply(); + PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( + objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); + plocSupervisor->setStartUpImmediately(); #endif #if OBSW_ADD_SPI_TEST_CODE == 1 - new SpiTestClass(objects::SPI_TEST, gpioComIF); + new SpiTestClass(objects::SPI_TEST, gpioComIF); #endif - } diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 0e723142..47e06e33 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -11,7 +11,7 @@ void setStatics(); void produce(void* args); void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, - SpiComIF** spiComIF); + SpiComIF** spiComIF); void createTmpComponents(); void createPcduComponents(); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); @@ -22,9 +22,9 @@ void createSolarArrayDeploymentComponents(); void createSyrlinksComponents(); void createRtdComponents(LinuxLibgpioIF* gpioComIF); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF); -void createCcsdsComponents(LinuxLibgpioIF *gpioComIF); +void createCcsdsComponents(LinuxLibgpioIF* gpioComIF); void createTestComponents(LinuxLibgpioIF* gpioComIF); -}; +}; // namespace ObjectFactory #endif /* BSP_Q7S_OBJECTFACTORY_H_ */ diff --git a/bsp_q7s/core/ParameterHandler.cpp b/bsp_q7s/core/ParameterHandler.cpp index d6c8f34f..8cee046e 100644 --- a/bsp_q7s/core/ParameterHandler.cpp +++ b/bsp_q7s/core/ParameterHandler.cpp @@ -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; } diff --git a/bsp_q7s/core/ParameterHandler.h b/bsp_q7s/core/ParameterHandler.h index 81cbc099..4a108586 100644 --- a/bsp_q7s/core/ParameterHandler.h +++ b/bsp_q7s/core/ParameterHandler.h @@ -4,19 +4,17 @@ #include #include - - class ParameterHandler { -public: - ParameterHandler(std::string mountPrefix); + public: + ParameterHandler(std::string mountPrefix); - void setMountPrefix(std::string prefix); + void setMountPrefix(std::string prefix); - void setUpDummyParameter(); -private: - std::string mountPrefix; - DummyParameter dummyParam; + void setUpDummyParameter(); + + private: + std::string mountPrefix; + DummyParameter dummyParam; }; - #endif /* BSP_Q7S_CORE_PARAMETERHANDLER_H_ */ diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index a332d67e..04163a82 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -1,43 +1,44 @@ #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 #include +#include + +#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; int obsw::obsw() { - std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- EIVE OBSW --" << std::endl; #if BOARD_TE0720 == 0 - std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; + std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; #else - std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; + 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 << "-- " << __DATE__ << " " << __TIME__ << " --" << 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; - return OBSW_ALREADY_RUNNING; - } + // 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; + return OBSW_ALREADY_RUNNING; + } #endif - initmission::initMission(); + initmission::initMission(); - for(;;) { - /* Suspend main thread by sleeping it. */ - TaskFactory::delayTask(5000); - } - return 0; + for (;;) { + /* Suspend main thread by sleeping it. */ + TaskFactory::delayTask(5000); + } + return 0; } diff --git a/bsp_q7s/devices/PlocMemoryDumper.cpp b/bsp_q7s/devices/PlocMemoryDumper.cpp index cc4361bb..c7ba58bd 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.cpp +++ b/bsp_q7s/devices/PlocMemoryDumper.cpp @@ -1,206 +1,192 @@ -#include -#include "fsfw/ipc/QueueFactory.h" #include "PlocMemoryDumper.h" -#include +#include + #include +#include #include -PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) : - SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +#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; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocMemoryDumper::performOperation(uint8_t operationCode) { - readCommandQueue(); - doStateMachine(); - return HasReturnvaluesIF::RETURN_OK; + readCommandQueue(); + doStateMachine(); + 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; + } - if (state != State::IDLE) { - return IS_BUSY; - } - - switch (actionId) { + switch (actionId) { case DUMP_MRAM: { - size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress); - SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize, - SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize, - SerializeIF::Endianness::BIG); - if (mram.endAddress > MAX_MRAM_ADDRESS) { - return MRAM_ADDRESS_TOO_HIGH; - } - if (mram.endAddress <= mram.startAddress) { - return MRAM_INVALID_ADDRESS_COMBINATION; - } - state = State::COMMAND_FIRST_MRAM_DUMP; - break; + size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress); + SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize, + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize, + SerializeIF::Endianness::BIG); + if (mram.endAddress > MAX_MRAM_ADDRESS) { + return MRAM_ADDRESS_TOO_HIGH; + } + if (mram.endAddress <= mram.startAddress) { + return MRAM_INVALID_ADDRESS_COMBINATION; + } + state = State::COMMAND_FIRST_MRAM_DUMP; + break; } default: { - sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" - << std::endl; - return INVALID_ACTION_ID; - } + sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" + << std::endl; + return INVALID_ACTION_ID; } + } - return EXECUTION_FINISHED; + 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; - ReturnValue_t result; + CommandMessage message; + ReturnValue_t result; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - if (result != RETURN_OK) { - continue; - } - result = actionHelper.handleActionMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format" - << std::endl; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format" + << std::endl; + } } void PlocMemoryDumper::doStateMachine() { - switch (state) { + switch (state) { case State::IDLE: - break; + break; case State::COMMAND_FIRST_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); - break; + commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); + break; case State::COMMAND_CONSECUTIVE_MRAM_DUMP: - commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); - break; + commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + break; case State::EXECUTING_MRAM_DUMP: - break; + break; default: - sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl; + break; + } } -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) { + switch (pendingCommand) { case (PLOC_SPV::FIRST_MRAM_DUMP): case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - if (mram.endAddress == mram.startAddress) { - triggerEvent(MRAM_DUMP_FINISHED); - state = State::IDLE; - } - else { - state = State::COMMAND_CONSECUTIVE_MRAM_DUMP; - } - break; - default: - sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command" - << std::endl; + if (mram.endAddress == mram.startAddress) { + triggerEvent(MRAM_DUMP_FINISHED); state = State::IDLE; - break; - } + } else { + state = State::COMMAND_CONSECUTIVE_MRAM_DUMP; + } + break; + default: + sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } } -void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - switch(pendingCommand) { - case(PLOC_SPV::FIRST_MRAM_DUMP): - case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); - break; +void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { + switch (pendingCommand) { + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); + break; default: - sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command " - << std::endl; - break; - } - state = State::IDLE; + sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command " + << std::endl; + break; + } + state = State::IDLE; } void PlocMemoryDumper::commandNextMramDump(ActionId_t dumpCommand) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - uint32_t tempStartAddress = 0; - uint32_t tempEndAddress = 0; + uint32_t tempStartAddress = 0; + uint32_t tempEndAddress = 0; - if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) { - tempStartAddress = mram.startAddress; - tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE; - mram.startAddress += MAX_MRAM_DUMP_SIZE; - mram.lastStartAddress = tempStartAddress; - } - else { - tempStartAddress = mram.startAddress; - tempEndAddress = mram.endAddress; - mram.startAddress = mram.endAddress; - } + if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE; + mram.startAddress += MAX_MRAM_DUMP_SIZE; + mram.lastStartAddress = tempStartAddress; + } else { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.endAddress; + mram.startAddress = mram.endAddress; + } - MemoryParams params(tempStartAddress, tempEndAddress); + MemoryParams params(tempStartAddress, tempEndAddress); - 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 " - << tempEndAddress << std::endl; - triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress); - state = State::IDLE; - pendingCommand = NONE; - return; - } - state = State::EXECUTING_MRAM_DUMP; - pendingCommand = dumpCommand; + 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 " + << tempEndAddress << std::endl; + triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress); + state = State::IDLE; + pendingCommand = NONE; return; + } + state = State::EXECUTING_MRAM_DUMP; + pendingCommand = dumpCommand; + return; } - diff --git a/bsp_q7s/devices/PlocMemoryDumper.h b/bsp_q7s/devices/PlocMemoryDumper.h index 72b031ae..2ee26824 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.h +++ b/bsp_q7s/devices/PlocMemoryDumper.h @@ -3,18 +3,18 @@ #include #include + #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 @@ -25,91 +25,90 @@ * @author J. Meier */ class PlocMemoryDumper : public SystemObject, - public HasActionsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF, - public CommandsActionsIF { -public: + public HasActionsIF, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public CommandsActionsIF { + public: + static const ActionId_t NONE = 0; + static const ActionId_t DUMP_MRAM = 1; - static const ActionId_t NONE = 0; - static const ActionId_t DUMP_MRAM = 1; + PlocMemoryDumper(object_id_t objectId); + virtual ~PlocMemoryDumper(); - PlocMemoryDumper(object_id_t objectId); - virtual ~PlocMemoryDumper(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); - MessageQueueId_t getCommandQueue() const; - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + private: + static const uint32_t QUEUE_SIZE = 10; -private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; - static const uint32_t QUEUE_SIZE = 10; + //! [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); - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_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. - 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); + //! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler + //! P1: Return value of commandAction function + //! P2: Start address of MRAM to dump with this command + static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler + //! P1: MRAM start address of failing dump command + static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] MRAM dump finished successfully + static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MEMORY_DUMPER; + // Maximum size of mram dump which can be retrieved with one command + static const uint32_t MAX_MRAM_DUMP_SIZE = 100000; + static const uint32_t MAX_MRAM_ADDRESS = 0x7d000; - //! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler - //! P1: Return value of commandAction function - //! P2: Start address of MRAM to dump with this command - static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler - //! P1: MRAM start address of failing dump command - static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] MRAM dump finished successfully - static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW); + MessageQueueIF* commandQueue = nullptr; - // Maximum size of mram dump which can be retrieved with one command - static const uint32_t MAX_MRAM_DUMP_SIZE = 100000; - static const uint32_t MAX_MRAM_ADDRESS = 0x7d000; + CommandActionHelper commandActionHelper; - MessageQueueIF* commandQueue = nullptr; + ActionHelper actionHelper; - CommandActionHelper commandActionHelper; + enum class State : uint8_t { + IDLE, + COMMAND_FIRST_MRAM_DUMP, + COMMAND_CONSECUTIVE_MRAM_DUMP, + EXECUTING_MRAM_DUMP + }; - ActionHelper actionHelper; + State state = State::IDLE; - enum class State: uint8_t { - IDLE, - COMMAND_FIRST_MRAM_DUMP, - COMMAND_CONSECUTIVE_MRAM_DUMP, - EXECUTING_MRAM_DUMP - }; + ActionId_t pendingCommand = NONE; - State state = State::IDLE; + typedef struct MemoryInfo { + // Stores the start address of the next memory range to dump + uint32_t startAddress; + uint32_t endAddress; + // Stores the start address of the last sent dump command + uint32_t lastStartAddress; + } MemoryInfo_t; - ActionId_t pendingCommand = NONE; + MemoryInfo_t mram = {0, 0, 0}; - typedef struct MemoryInfo { - // Stores the start address of the next memory range to dump - uint32_t startAddress; - uint32_t endAddress; - // Stores the start address of the last sent dump command - uint32_t lastStartAddress; - } MemoryInfo_t; + void readCommandQueue(); + void doStateMachine(); - MemoryInfo_t mram = {0, 0, 0}; - - void readCommandQueue(); - void doStateMachine(); - - /** - * @brief Sends the next mram dump command to the PLOC supervisor handler. - */ - void commandNextMramDump(ActionId_t dumpCommand); + /** + * @brief Sends the next mram dump command to the PLOC supervisor handler. + */ + void commandNextMramDump(ActionId_t dumpCommand); }; #endif /* MISSION_DEVICES_PLOCMEMORYDUMPER_H_ */ diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index 30ea9572..a56c9e1c 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -1,540 +1,530 @@ -#include -#include -#include -#include - #include "PlocSupervisorHandler.h" -#include "OBSWConfig.h" -#include #include +#include #include +#include +#include +#include +#include + +#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) { - if (comCookie == NULL) { - sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl; - } + 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; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } - uartComIf = dynamic_cast(communicationInterface); - if (uartComIf == nullptr) { - sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl; - return INVALID_UART_COM_IF; - } + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + uartComIf = dynamic_cast(communicationInterface); + if (uartComIf == nullptr) { + sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl; + return INVALID_UART_COM_IF; + } #if BOARD_TE0720 == 0 - sdcMan = SdCardManager::instance(); + sdcMan = SdCardManager::instance(); #endif /* BOARD_TE0720 == 0 */ - return result; + return result; } - -void PlocSupervisorHandler::doStartUp(){ +void PlocSupervisorHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void PlocSupervisorHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +void PlocSupervisorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } -ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return NOTHING_TO_SEND; +ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } -ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return NOTHING_TO_SEND; -} - -ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_FAILED; - switch(deviceCommand) { - case(PLOC_SPV::GET_HK_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); - result = RETURN_OK; - break; - } - case(PLOC_SPV::RESTART_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::START_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::SHUTDOWN_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); - result = RETURN_OK; - break; - } - case(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { - prepareSelBootImageCmd(commandData); - result = RETURN_OK; - break; - } - case(PLOC_SPV::RESET_MPSOC): { - prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC); - result = RETURN_OK; - break; +ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_FAILED; + switch (deviceCommand) { + case (PLOC_SPV::GET_HK_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_TIME_REF): { - result = prepareSetTimeRefCmd(); - break; - } - case(PLOC_SPV::SET_BOOT_TIMEOUT): { - prepareSetBootTimeoutCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RESTART_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_MAX_RESTART_TRIES): { - prepareRestartTriesCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::START_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): { - prepareDisableHk(); - result = RETURN_OK; - break; + case (PLOC_SPV::SHUTDOWN_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::GET_BOOT_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT); - result = RETURN_OK; - break; + case (PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { + prepareSelBootImageCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::WATCHDOGS_ENABLE): { - prepareWatchdogsEnableCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RESET_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC); + result = RETURN_OK; + break; } - case(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT): { - result = prepareWatchdogsConfigTimeoutCmd(commandData); - break; + case (PLOC_SPV::SET_TIME_REF): { + result = prepareSetTimeRefCmd(); + break; } - case(PLOC_SPV::ENABLE_LATCHUP_ALERT): { - result = prepareLatchupConfigCmd(commandData, deviceCommand); - break; + case (PLOC_SPV::SET_BOOT_TIMEOUT): { + prepareSetBootTimeoutCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::DISABLE_LATCHUP_ALERT): { - result = prepareLatchupConfigCmd(commandData, deviceCommand); - break; + case (PLOC_SPV::SET_MAX_RESTART_TRIES): { + prepareRestartTriesCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::AUTO_CALIBRATE_ALERT): { - result = prepareAutoCalibrateAlertCmd(commandData); - break; + case (PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): { + prepareDisableHk(); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ALERT_LIMIT): { - result = prepareSetAlertLimitCmd(commandData); - break; + case (PLOC_SPV::GET_BOOT_STATUS_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ALERT_IRQ_FILTER): { - result = prepareSetAlertIrqFilterCmd(commandData); - break; + case (PLOC_SPV::WATCHDOGS_ENABLE): { + prepareWatchdogsEnableCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_ADC_SWEEP_PERIOD): { - result = prepareSetAdcSweetPeriodCmd(commandData); - break; + case (PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT): { + result = prepareWatchdogsConfigTimeoutCmd(commandData); + break; } - case(PLOC_SPV::SET_ADC_ENABLED_CHANNELS): { - prepareSetAdcEnabledChannelsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { + result = prepareLatchupConfigCmd(commandData, deviceCommand); + break; } - case(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE): { - prepareSetAdcWindowAndStrideCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { + result = prepareLatchupConfigCmd(commandData, deviceCommand); + break; } - case(PLOC_SPV::SET_ADC_THRESHOLD): { - prepareSetAdcThresholdCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::AUTO_CALIBRATE_ALERT): { + result = prepareAutoCalibrateAlertCmd(commandData); + break; } - case(PLOC_SPV::GET_LATCHUP_STATUS_REPORT): { - prepareEmptyCmd(PLOC_SPV::APID_GET_LATCHUP_STATUS_REPORT); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ALERT_LIMIT): { + result = prepareSetAlertLimitCmd(commandData); + break; } - case(PLOC_SPV::COPY_ADC_DATA_TO_MRAM): { - prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ALERT_IRQ_FILTER): { + result = prepareSetAlertIrqFilterCmd(commandData); + break; } - case(PLOC_SPV::ENABLE_NVMS): { - prepareEnableNvmsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ADC_SWEEP_PERIOD): { + result = prepareSetAdcSweetPeriodCmd(commandData); + break; } - case(PLOC_SPV::SELECT_NVM): { - prepareSelectNvmCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SET_ADC_ENABLED_CHANNELS): { + prepareSetAdcEnabledChannelsCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::RUN_AUTO_EM_TESTS): { - result = prepareRunAutoEmTest(commandData); - break; + case (PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE): { + prepareSetAdcWindowAndStrideCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::WIPE_MRAM): { - result = prepareWipeMramCmd(commandData); - break; + case (PLOC_SPV::SET_ADC_THRESHOLD): { + prepareSetAdcThresholdCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::FIRST_MRAM_DUMP): - case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - result = prepareDumpMramCmd(commandData); - break; - case(PLOC_SPV::PRINT_CPU_STATS): { - preparePrintCpuStatsCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::GET_LATCHUP_STATUS_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_LATCHUP_STATUS_REPORT); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_DBG_VERBOSITY): { - prepareSetDbgVerbosityCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::COPY_ADC_DATA_TO_MRAM): { + prepareEmptyCmd(PLOC_SPV::APID_COPY_ADC_DATA_TO_MRAM); + result = RETURN_OK; + break; } - case(PLOC_SPV::CAN_LOOPBACK_TEST): { - prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST); - result = RETURN_OK; - break; + case (PLOC_SPV::ENABLE_NVMS): { + prepareEnableNvmsCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::SET_GPIO): { - prepareSetGpioCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::SELECT_NVM): { + prepareSelectNvmCmd(commandData); + result = RETURN_OK; + break; } - case(PLOC_SPV::READ_GPIO): { - prepareReadGpioCmd(commandData); - result = RETURN_OK; - break; + case (PLOC_SPV::RUN_AUTO_EM_TESTS): { + result = prepareRunAutoEmTest(commandData); + break; } - case(PLOC_SPV::RESTART_SUPERVISOR): { - prepareEmptyCmd(PLOC_SPV::APID_RESTART_SUPERVISOR); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_ALL): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CLEAR_ALL); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::MIRROR_ENTRIES); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR): { - PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CIRCULAR_ENTRIES); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - result = RETURN_OK; - break; - } - case(PLOC_SPV::UPDATE_AVAILABLE): - case(PLOC_SPV::UPDATE_IMAGE_DATA): - case(PLOC_SPV::UPDATE_VERIFY): - // Simply forward data from PLOC Updater to supervisor - std::memcpy(commandBuffer, commandData, commandDataLen); - rawPacket = commandBuffer; - rawPacketLen = commandDataLen; - nextReplyId = PLOC_SPV::ACK_REPORT; - result = RETURN_OK; - break; - default: - sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" - << std::endl; - result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - break; - } - - if (result == RETURN_OK) { - /** - * Flushing the receive buffer to make sure there are no data left from a faulty reply. - */ - uartComIf->flushUartRxBuffer(comCookie); - } - - return result; -} - -void PlocSupervisorHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); - this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); - this->insertInCommandMap(PLOC_SPV::START_MPSOC); - this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); - this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); - this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); - this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); - this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); - this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION); - this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE); - this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY); - this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE); - this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT); - this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::DISABLE_LATCHUP_ALERT); - this->insertInCommandMap(PLOC_SPV::AUTO_CALIBRATE_ALERT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_LIMIT); - this->insertInCommandMap(PLOC_SPV::SET_ALERT_IRQ_FILTER); - this->insertInCommandMap(PLOC_SPV::SET_ADC_SWEEP_PERIOD); - this->insertInCommandMap(PLOC_SPV::SET_ADC_ENABLED_CHANNELS); - this->insertInCommandMap(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE); - this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD); - this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT); - this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM); - this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS); - this->insertInCommandMap(PLOC_SPV::SELECT_NVM); - this->insertInCommandMap(PLOC_SPV::RUN_AUTO_EM_TESTS); - this->insertInCommandMap(PLOC_SPV::WIPE_MRAM); - this->insertInCommandMap(PLOC_SPV::PRINT_CPU_STATS); - this->insertInCommandMap(PLOC_SPV::SET_DBG_VERBOSITY); - this->insertInCommandMap(PLOC_SPV::SET_GPIO); - this->insertInCommandMap(PLOC_SPV::READ_GPIO); - this->insertInCommandMap(PLOC_SPV::RESTART_SUPERVISOR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); - this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); - this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); - this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); - this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); - this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); - this->insertInReplyMap(PLOC_SPV::BOOT_STATUS_REPORT, 3, &bootStatusReport, - PLOC_SPV::SIZE_BOOT_STATUS_REPORT); - this->insertInReplyMap(PLOC_SPV::LATCHUP_REPORT, 3, &latchupStatusReport, - PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); -} - -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) { - *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; - return parseMramPackets(start, remainingSize, foundLen); - } - - ReturnValue_t result = RETURN_OK; - - uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; - - switch(apid) { - case(PLOC_SPV::APID_ACK_SUCCESS): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; - break; - case(PLOC_SPV::APID_ACK_FAILURE): - *foundLen = PLOC_SPV::SIZE_ACK_REPORT; - *foundId = PLOC_SPV::ACK_REPORT; - break; - case(PLOC_SPV::APID_HK_REPORT): - *foundLen = PLOC_SPV::SIZE_HK_REPORT; - *foundId = PLOC_SPV::HK_REPORT; - break; - case(PLOC_SPV::APID_BOOT_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_BOOT_STATUS_REPORT; - *foundId = PLOC_SPV::BOOT_STATUS_REPORT; - break; - case(PLOC_SPV::APID_LATCHUP_STATUS_REPORT): - *foundLen = PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT; - *foundId = PLOC_SPV::LATCHUP_REPORT; - break; - case(PLOC_SPV::APID_EXE_SUCCESS): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; - break; - case(PLOC_SPV::APID_EXE_FAILURE): - *foundLen = PLOC_SPV::SIZE_EXE_REPORT; - *foundId = PLOC_SPV::EXE_REPORT; - break; - default: { - sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; - *foundLen = remainingSize; - return INVALID_APID; - } - } - - return result; -} - -ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - - ReturnValue_t result = RETURN_OK; - - switch (id) { - case PLOC_SPV::ACK_REPORT: { - result = handleAckReport(packet); - break; - } - case (PLOC_SPV::HK_REPORT): { - result = handleHkReport(packet); - break; - } - case (PLOC_SPV::BOOT_STATUS_REPORT): { - result = handleBootStatusReport(packet); - break; - } - case (PLOC_SPV::LATCHUP_REPORT): { - result = handleLatchupStatusReport(packet); - break; + case (PLOC_SPV::WIPE_MRAM): { + result = prepareWipeMramCmd(commandData); + break; } case (PLOC_SPV::FIRST_MRAM_DUMP): case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): - result = handleMramDumpPacket(id); - break; + result = prepareDumpMramCmd(commandData); + break; + case (PLOC_SPV::PRINT_CPU_STATS): { + preparePrintCpuStatsCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::SET_DBG_VERBOSITY): { + prepareSetDbgVerbosityCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::CAN_LOOPBACK_TEST): { + prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST); + result = RETURN_OK; + break; + } + case (PLOC_SPV::SET_GPIO): { + prepareSetGpioCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::READ_GPIO): { + prepareReadGpioCmd(commandData); + result = RETURN_OK; + break; + } + case (PLOC_SPV::RESTART_SUPERVISOR): { + prepareEmptyCmd(PLOC_SPV::APID_RESTART_SUPERVISOR); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_ALL): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CLEAR_ALL); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::MIRROR_ENTRIES); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR): { + PLOC_SPV::FactoryReset packet(PLOC_SPV::FactoryReset::Op::CIRCULAR_ENTRIES); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (PLOC_SPV::UPDATE_AVAILABLE): + case (PLOC_SPV::UPDATE_IMAGE_DATA): + case (PLOC_SPV::UPDATE_VERIFY): + // Simply forward data from PLOC Updater to supervisor + std::memcpy(commandBuffer, commandData, commandDataLen); + rawPacket = commandBuffer; + rawPacketLen = commandDataLen; + nextReplyId = PLOC_SPV::ACK_REPORT; + result = RETURN_OK; + break; + default: + sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" + << std::endl; + result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + break; + } + + if (result == RETURN_OK) { + /** + * Flushing the receive buffer to make sure there are no data left from a faulty reply. + */ + uartComIf->flushUartRxBuffer(comCookie); + } + + return result; +} + +void PlocSupervisorHandler::fillCommandAndReplyMap() { + this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); + this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); + this->insertInCommandMap(PLOC_SPV::START_MPSOC); + this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); + this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); + this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); + this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); + this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); + this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); + this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION); + this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT); + this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE); + this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY); + this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA); + this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE); + this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT); + this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT); + this->insertInCommandMap(PLOC_SPV::DISABLE_LATCHUP_ALERT); + this->insertInCommandMap(PLOC_SPV::AUTO_CALIBRATE_ALERT); + this->insertInCommandMap(PLOC_SPV::SET_ALERT_LIMIT); + this->insertInCommandMap(PLOC_SPV::SET_ALERT_IRQ_FILTER); + this->insertInCommandMap(PLOC_SPV::SET_ADC_SWEEP_PERIOD); + this->insertInCommandMap(PLOC_SPV::SET_ADC_ENABLED_CHANNELS); + this->insertInCommandMap(PLOC_SPV::SET_ADC_WINDOW_AND_STRIDE); + this->insertInCommandMap(PLOC_SPV::SET_ADC_THRESHOLD); + this->insertInCommandMap(PLOC_SPV::GET_LATCHUP_STATUS_REPORT); + this->insertInCommandMap(PLOC_SPV::COPY_ADC_DATA_TO_MRAM); + this->insertInCommandMap(PLOC_SPV::ENABLE_NVMS); + this->insertInCommandMap(PLOC_SPV::SELECT_NVM); + this->insertInCommandMap(PLOC_SPV::RUN_AUTO_EM_TESTS); + this->insertInCommandMap(PLOC_SPV::WIPE_MRAM); + this->insertInCommandMap(PLOC_SPV::PRINT_CPU_STATS); + this->insertInCommandMap(PLOC_SPV::SET_DBG_VERBOSITY); + this->insertInCommandMap(PLOC_SPV::SET_GPIO); + this->insertInCommandMap(PLOC_SPV::READ_GPIO); + this->insertInCommandMap(PLOC_SPV::RESTART_SUPERVISOR); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); + this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); + this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); + this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); + this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); + this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); + this->insertInReplyMap(PLOC_SPV::BOOT_STATUS_REPORT, 3, &bootStatusReport, + PLOC_SPV::SIZE_BOOT_STATUS_REPORT); + this->insertInReplyMap(PLOC_SPV::LATCHUP_REPORT, 3, &latchupStatusReport, + PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); +} + +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) { + *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + return parseMramPackets(start, remainingSize, foundLen); + } + + ReturnValue_t result = RETURN_OK; + + uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; + + switch (apid) { + case (PLOC_SPV::APID_ACK_SUCCESS): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case (PLOC_SPV::APID_ACK_FAILURE): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case (PLOC_SPV::APID_HK_REPORT): + *foundLen = PLOC_SPV::SIZE_HK_REPORT; + *foundId = PLOC_SPV::HK_REPORT; + break; + case (PLOC_SPV::APID_BOOT_STATUS_REPORT): + *foundLen = PLOC_SPV::SIZE_BOOT_STATUS_REPORT; + *foundId = PLOC_SPV::BOOT_STATUS_REPORT; + break; + case (PLOC_SPV::APID_LATCHUP_STATUS_REPORT): + *foundLen = PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT; + *foundId = PLOC_SPV::LATCHUP_REPORT; + break; + case (PLOC_SPV::APID_EXE_SUCCESS): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + case (PLOC_SPV::APID_EXE_FAILURE): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + default: { + sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; + *foundLen = remainingSize; + return INVALID_APID; + } + } + + return result; +} + +ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; + + switch (id) { + case PLOC_SPV::ACK_REPORT: { + result = handleAckReport(packet); + break; + } + case (PLOC_SPV::HK_REPORT): { + result = handleHkReport(packet); + break; + } + case (PLOC_SPV::BOOT_STATUS_REPORT): { + result = handleBootStatusReport(packet); + break; + } + case (PLOC_SPV::LATCHUP_REPORT): { + result = handleLatchupStatusReport(packet); + break; + } + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + result = handleMramDumpPacket(id); + break; case (PLOC_SPV::EXE_REPORT): { - result = handleExecutionReport(packet); - break; + result = handleExecutionReport(packet); + break; } default: { - sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" + << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + 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) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_ID, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT0, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT1, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT2, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT3, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT4, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT5, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::CNT6, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_SEC, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MIN, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_HOUR, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_DAY, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry({0})); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry({0})); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::CNT6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_SEC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MIN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_HOUR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_DAY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies, bool useAlternateId, - DeviceCommandId_t alternateReplyID) { + uint8_t expectedReplies, + bool useAlternateId, + DeviceCommandId_t alternateReplyID) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint8_t enabledReplies = 0; - uint8_t enabledReplies = 0; - - switch (command->first) { + switch (command->first) { case PLOC_SPV::GET_HK_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::HK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::HK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::GET_BOOT_STATUS_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::BOOT_STATUS_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::BOOT_STATUS_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::BOOT_STATUS_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::LATCHUP_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::LATCHUP_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::FIRST_MRAM_DUMP: { - enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::FIRST_MRAM_DUMP); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; - } - break; + enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::FIRST_MRAM_DUMP); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: { - enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::CONSECUTIVE_MRAM_DUMP); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; - } - break; + enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; + } + break; } case PLOC_SPV::RESTART_MPSOC: case PLOC_SPV::START_MPSOC: @@ -574,957 +564,948 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite case PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR: case PLOC_SPV::REQUEST_LOGGING_DATA: case PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION: - enabledReplies = 2; - break; + enabledReplies = 2; + break; default: - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl; - break; - } + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + break; + } - /** - * 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); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl; - } + /** + * 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); + 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); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl; - } + 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; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t foundLen) { + uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); - uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); + uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); - uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); + if (receivedCrc != recalculatedCrc) { + return CRC_FAILURE; + } - if (receivedCrc != recalculatedCrc) { - return CRC_FAILURE; - } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); + triggerEvent(SUPV_CRC_FAILURE_EVENT); + sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); + disableAllReplies(); + return RETURN_OK; + } - result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; - replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); - triggerEvent(SUPV_CRC_FAILURE_EVENT); - sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); - disableAllReplies(); - return RETURN_OK; + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + 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; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(SUPV_ACK_FAILURE, commandId); + } + sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); + disableAllReplies(); + nextReplyId = PLOC_SPV::NONE; + result = IGNORE_REPLY_DATA; + break; } + case PLOC_SPV::APID_ACK_SUCCESS: { + setNextReplyId(); + break; + } + default: { + sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" + << std::endl; + result = RETURN_FAILED; + break; + } + } - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - 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; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(SUPV_ACK_FAILURE, commandId); - } - sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); - disableAllReplies(); - nextReplyId = PLOC_SPV::NONE; - result = IGNORE_REPLY_DATA; - break; - } - case PLOC_SPV::APID_ACK_SUCCESS: { - setNextReplyId(); - break; - } - default: { - sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" << std::endl; - result = RETURN_FAILED; - break; - } - } - - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + return result; + } - result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC_SPV::NONE; - return result; - } + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch (apid) { + switch (apid) { case (PLOC_SPV::APID_EXE_SUCCESS): { - break; + break; } case (PLOC_SPV::APID_EXE_FAILURE): { - //TODO: Interpretation of status field in execution 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; - } - sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); - disableExeReportReply(); - result = IGNORE_REPLY_DATA; - break; + // TODO: Interpretation of status field in execution 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; + } + sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); + disableExeReportReply(); + result = IGNORE_REPLY_DATA; + break; } default: { - sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl; - result = RETURN_FAILED; - break; - } + sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl; + result = RETURN_FAILED; + break; } + } - nextReplyId = PLOC_SPV::NONE; + nextReplyId = PLOC_SPV::NONE; - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" << std::endl; + } - if(result == CRC_FAILURE) { - 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); + offset += 4; + 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); + offset += 4; + 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); + offset += 4; + 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); + offset += 4; + 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); + offset += 4; + hkset.nvm0_1_state = *(data + offset); + offset += 1; + hkset.nvm3_state = *(data + offset); + offset += 1; + hkset.missionIoState = *(data + offset); + offset += 1; + hkset.fmcState = *(data + offset); + offset += 1; - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - 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); - offset += 4; - 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); - offset += 4; - 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); - offset += 4; - 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); - offset += 4; - 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; - hkset.nvm3_state = *(data + offset); - offset += 1; - hkset.missionIoState = *(data + offset); - offset += 1; - hkset.fmcState = *(data + offset); - offset += 1; - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; - 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: 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; - sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; + 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: 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; + sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: " << static_cast(hkset.nvm0_1_state.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: nvm3_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: nvm3_state: " << static_cast(hkset.nvm3_state.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: missoin_io_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: missoin_io_state: " << static_cast(hkset.missionIoState.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: " + sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: " << static_cast(hkset.fmcState.value) << std::endl; #endif - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT); - 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; + return result; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid" - " crc" << std::endl; - return result; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + bootStatusReport.bootSignal = *(data + offset); + offset += 1; + bootStatusReport.resetCounter = *(data + offset); + offset += 1; + bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + bootStatusReport.activeNvm = *(data + offset); + offset += 1; + bootStatusReport.bp0State = *(data + offset); + offset += 1; + bootStatusReport.bp1State = *(data + offset); + offset += 1; + bootStatusReport.bp2State = *(data + offset); - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - bootStatusReport.bootSignal = *(data + offset); - offset += 1; - bootStatusReport.resetCounter = *(data + offset); - offset += 1; - bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - bootStatusReport.activeNvm = *(data + offset); - offset += 1; - bootStatusReport.bp0State = *(data + offset); - offset += 1; - bootStatusReport.bp1State = *(data + offset); - offset += 1; - bootStatusReport.bp2State = *(data + offset); - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " << static_cast(bootStatusReport.bootSignal.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " << static_cast(bootStatusReport.resetCounter.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " << bootStatusReport.bootAfterMs << " ms" << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " << bootStatusReport.bootTimeoutMs << " ms" << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: " << static_cast(bootStatusReport.activeNvm.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: " << static_cast(bootStatusReport.bp0State.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " << static_cast(bootStatusReport.bp1State.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " + sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " << static_cast(bootStatusReport.bp2State.value) << std::endl; #endif - return result; + return result; } ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); - result = verifyPacket(data, PLOC_SPV::SIZE_LATCHUP_STATUS_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has " + << "invalid crc" << std::endl; + return result; + } - if(result == CRC_FAILURE) { - sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has " - << "invalid crc" << std::endl; - return result; - } + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + latchupStatusReport.id = *(data + offset); + offset += 1; + latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt1 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt2 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt3 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt4 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt5 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1); + offset += 2; + latchupStatusReport.timeSec = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMin = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeHour = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeDay = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMon = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeYear = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; + latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; - uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; - latchupStatusReport.id = *(data + offset); - offset += 1; - latchupStatusReport.cnt0 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt1 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt2 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt3 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt4 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt5 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1); - offset += 2; - latchupStatusReport.timeSec = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMin = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeHour = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeDay = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMon = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeYear = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | - *(data + offset + 2) << 8 | *(data + offset + 3); - offset += 4; - - nextReplyId = PLOC_SPV::EXE_REPORT; + nextReplyId = PLOC_SPV::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " << static_cast(latchupStatusReport.id.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT0: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT0: " << latchupStatusReport.cnt0 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT1: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT1: " << latchupStatusReport.cnt1 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT2: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT2: " << latchupStatusReport.cnt2 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT3: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT3: " << latchupStatusReport.cnt3 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT4: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT4: " << latchupStatusReport.cnt4 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT5: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT5: " << latchupStatusReport.cnt5 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT6: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT6: " << latchupStatusReport.cnt6 << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Sec: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Sec: " << latchupStatusReport.timeSec << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Min: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Min: " << latchupStatusReport.timeMin << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Hour: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Hour: " << latchupStatusReport.timeHour << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Day: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Day: " << latchupStatusReport.timeDay << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Mon: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Mon: " << latchupStatusReport.timeMon << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Year: " + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Year: " << latchupStatusReport.timeYear << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " + 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; + return result; } void PlocSupervisorHandler::setNextReplyId() { - switch(getPendingCommand()) { + switch (getPendingCommand()) { case PLOC_SPV::GET_HK_REPORT: - nextReplyId = PLOC_SPV::HK_REPORT; - break; + nextReplyId = PLOC_SPV::HK_REPORT; + break; case PLOC_SPV::GET_BOOT_STATUS_REPORT: - nextReplyId = PLOC_SPV::BOOT_STATUS_REPORT; - break; + nextReplyId = PLOC_SPV::BOOT_STATUS_REPORT; + break; case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: - nextReplyId = PLOC_SPV::LATCHUP_REPORT; - break; + nextReplyId = PLOC_SPV::LATCHUP_REPORT; + break; case PLOC_SPV::FIRST_MRAM_DUMP: - nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; - break; + nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; + break; case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: - nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; - break; + nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; + break; default: - /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC_SPV::EXE_REPORT; - break; - } + /* If no telemetry is expected the next reply is always the execution report */ + nextReplyId = PLOC_SPV::EXE_REPORT; + break; + } } -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) { - /** - * 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 - * count indicating the last packet has not been received. - */ - replyLen = PLOC_SPV::MAX_PACKET_SIZE * 20; - return replyLen; - } - - DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); - if (iter != deviceReplyMap.end()) { - if (iter->second.delayCycles == 0) { - /* Reply inactive */ - return replyLen; - } - replyLen = iter->second.replyLen; - } - else { - sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id " - << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; - } +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) { + /** + * 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 + * count indicating the last packet has not been received. + */ + replyLen = PLOC_SPV::MAX_PACKET_SIZE * 20; + return replyLen; + } + + DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles == 0) { + /* Reply inactive */ + return replyLen; + } + replyLen = iter->second.replyLen; + } else { + sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id " + << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; + } + + 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; - ReturnValue_t result = RETURN_OK; + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::handleDeviceTM: Failed to report data" << std::endl; - } + result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Failed to report data" << std::endl; + } } void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) { - PLOC_SPV::EmptyPacket packet(apid); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + PLOC_SPV::EmptyPacket packet(apid); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t * commandData) { - PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), - *(commandData + 3)); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) { + PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), + *(commandData + 3)); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() { - Clock::TimeOfDay_t time; - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time" - << std::endl; - return GET_TIME_FAILURE; - } - PLOC_SPV::SetTimeRef packet(&time); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + Clock::TimeOfDay_t time; + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time" + << std::endl; + return GET_TIME_FAILURE; + } + PLOC_SPV::SetTimeRef packet(&time); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } void PlocSupervisorHandler::prepareDisableHk() { - PLOC_SPV::DisablePeriodicHkTransmission packet; - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + PLOC_SPV::DisablePeriodicHkTransmission packet; + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t * commandData) { - uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); - PLOC_SPV::SetBootTimeout packet(timeout); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t* commandData) { + uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + PLOC_SPV::SetBootTimeout packet(timeout); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t * commandData) { - uint8_t restartTries = *(commandData); - PLOC_SPV::SetRestartTries packet(restartTries); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t* commandData) { + uint8_t restartTries = *(commandData); + PLOC_SPV::SetRestartTries packet(restartTries); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t * commandData) { - uint8_t offset = 0; - uint8_t watchdogPs = *(commandData + offset); - offset += 1; - uint8_t watchdogPl = *(commandData + offset); - offset += 1; - uint8_t watchdogInt = *(commandData + offset); - PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); +void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t* commandData) { + uint8_t offset = 0; + uint8_t watchdogPs = *(commandData + offset); + offset += 1; + uint8_t watchdogPl = *(commandData + offset); + offset += 1; + uint8_t watchdogInt = *(commandData + offset); + PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } -ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint8_t * commandData) { - uint8_t offset = 0; - uint8_t watchdog = *(commandData + offset); - offset += 1; - if (watchdog > 2) { - return INVALID_WATCHDOG; - } - 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; - } - PLOC_SPV::WatchdogsConfigTimeout packet(watchdog, timeout); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; +ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData) { + uint8_t offset = 0; + uint8_t watchdog = *(commandData + offset); + offset += 1; + if (watchdog > 2) { + return INVALID_WATCHDOG; + } + 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; + } + PLOC_SPV::WatchdogsConfigTimeout packet(watchdog, timeout); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* commandData, - DeviceCommandId_t deviceCommand) { - ReturnValue_t result = RETURN_OK; - uint8_t latchupId = *commandData; - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - switch (deviceCommand) { + DeviceCommandId_t deviceCommand) { + ReturnValue_t result = RETURN_OK; + uint8_t latchupId = *commandData; + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + switch (deviceCommand) { case (PLOC_SPV::ENABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(true, latchupId); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - break; + PLOC_SPV::LatchupAlert packet(true, latchupId); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + break; } case (PLOC_SPV::DISABLE_LATCHUP_ALERT): { - PLOC_SPV::LatchupAlert packet(false, latchupId); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - break; + PLOC_SPV::LatchupAlert packet(false, latchupId); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + break; } default: { - sif::debug << "PlocSupervisorHandler::prepareLatchupConfigCmd: Invalid command id" - << std::endl; - result = RETURN_FAILED; - break; + sif::debug << "PlocSupervisorHandler::prepareLatchupConfigCmd: Invalid command id" + << std::endl; + result = RETURN_FAILED; + break; } - } - return result; + } + return result; } ReturnValue_t PlocSupervisorHandler::prepareAutoCalibrateAlertCmd(const uint8_t* commandData) { - 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); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::AutoCalibrateAlert packet(latchupId, mg); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + 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); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::AutoCalibrateAlert packet(latchupId, mg); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAlertIrqFilterCmd(const uint8_t* commandData) { - uint8_t latchupId = *commandData; - uint8_t tp = *(commandData + 1); - uint8_t div = *(commandData + 2); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::SetAlertIrqFilter packet(latchupId, tp, div); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t latchupId = *commandData; + uint8_t tp = *(commandData + 1); + uint8_t div = *(commandData + 2); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::SetAlertIrqFilter packet(latchupId, tp, div); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* commandData) { - 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); - if (latchupId > 6) { - return INVALID_LATCHUP_ID; - } - PLOC_SPV::SetAlertlimit packet(latchupId, dutycycle); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + 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); + if (latchupId > 6) { + return INVALID_LATCHUP_ID; + } + PLOC_SPV::SetAlertlimit packet(latchupId, dutycycle); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareSetAdcSweetPeriodCmd(const uint8_t* commandData) { - uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - if (sweepPeriod < 21) { - return SWEEP_PERIOD_TOO_SMALL; - } - PLOC_SPV::SetAdcSweepPeriod packet(sweepPeriod); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + if (sweepPeriod < 21) { + return SWEEP_PERIOD_TOO_SMALL; + } + PLOC_SPV::SetAdcSweepPeriod packet(sweepPeriod); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } void PlocSupervisorHandler::prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData) { - uint16_t ch = *(commandData) << 8 | *(commandData + 1); - PLOC_SPV::SetAdcEnabledChannels packet(ch); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint16_t ch = *(commandData) << 8 | *(commandData + 1); + PLOC_SPV::SetAdcEnabledChannels packet(ch); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData) { - uint8_t offset = 0; - uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1); - offset += 2; - uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1); - PLOC_SPV::SetAdcWindowAndStride packet(windowSize, stridingStepSize); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t offset = 0; + uint16_t windowSize = *(commandData + offset) << 8 | *(commandData + offset + 1); + offset += 2; + uint16_t stridingStepSize = *(commandData + offset) << 8 | *(commandData + offset + 1); + PLOC_SPV::SetAdcWindowAndStride packet(windowSize, stridingStepSize); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData) { - uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); - PLOC_SPV::SetAdcThreshold packet(threshold); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint32_t threshold = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | + *(commandData + 3); + PLOC_SPV::SetAdcThreshold packet(threshold); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareEnableNvmsCmd(const uint8_t* commandData) { - uint8_t n01 = *commandData; - uint8_t n3 = *(commandData + 1); - PLOC_SPV::EnableNvms packet(n01, n3); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t n01 = *commandData; + uint8_t n3 = *(commandData + 1); + PLOC_SPV::EnableNvms packet(n01, n3); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSelectNvmCmd(const uint8_t* commandData) { - uint8_t mem = *commandData; - PLOC_SPV::SelectNvm packet(mem); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t mem = *commandData; + PLOC_SPV::SelectNvm packet(mem); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* commandData) { - uint8_t test = *commandData; - if (test != 1 && test != 2) { - return INVALID_TEST_PARAM; - } - PLOC_SPV::RunAutoEmTests packet(test); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint8_t test = *commandData; + if (test != 1 && test != 2) { + return INVALID_TEST_PARAM; + } + PLOC_SPV::RunAutoEmTests packet(test); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandData) { - uint32_t start = 0; - uint32_t stop = 0; - size_t size = sizeof(start) + sizeof(stop); - SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); - if ((stop - start) <= 0) { - return INVALID_MRAM_ADDRESSES; - } - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - return RETURN_OK; + uint32_t start = 0; + uint32_t stop = 0; + size_t size = sizeof(start) + sizeof(stop); + SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); + if ((stop - start) <= 0) { + return INVALID_MRAM_ADDRESSES; + } + PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::WIPE); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandData) { - uint32_t start = 0; - uint32_t stop = 0; - size_t size = sizeof(start) + sizeof(stop); - SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); - PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); - if ((stop - start) <= 0) { - return INVALID_MRAM_ADDRESSES; - } - expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY; - if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) { - expectedMramDumpPackets++; - } - receivedMramDumpPackets = 0; - return RETURN_OK; + uint32_t start = 0; + uint32_t stop = 0; + size_t size = sizeof(start) + sizeof(stop); + SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG); + PLOC_SPV::MramCmd packet(start, stop, PLOC_SPV::MramCmd::MramAction::DUMP); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + if ((stop - start) <= 0) { + return INVALID_MRAM_ADDRESSES; + } + expectedMramDumpPackets = (stop - start) / PLOC_SPV::MAX_DATA_CAPACITY; + if ((stop - start) % PLOC_SPV::MAX_DATA_CAPACITY) { + expectedMramDumpPackets++; + } + receivedMramDumpPackets = 0; + return RETURN_OK; } void PlocSupervisorHandler::preparePrintCpuStatsCmd(const uint8_t* commandData) { - uint8_t en = *commandData; - PLOC_SPV::PrintCpuStats packet(en); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t en = *commandData; + PLOC_SPV::PrintCpuStats packet(en); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetDbgVerbosityCmd(const uint8_t* commandData) { - uint8_t vb = *commandData; - PLOC_SPV::SetDbgVerbosity packet(vb); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t vb = *commandData; + PLOC_SPV::SetDbgVerbosity packet(vb); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareSetGpioCmd(const uint8_t* commandData) { - uint8_t port = *commandData; - uint8_t pin = *(commandData + 1); - uint8_t val = *(commandData + 2); - PLOC_SPV::SetGpio packet(port, pin, val); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t port = *commandData; + uint8_t pin = *(commandData + 1); + uint8_t val = *(commandData + 2); + PLOC_SPV::SetGpio packet(port, pin, val); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandData) { - uint8_t port = *commandData; - uint8_t pin = *(commandData + 1); - PLOC_SPV::ReadGpio packet(port, pin); - packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + uint8_t port = *commandData; + uint8_t pin = *(commandData + 1); + PLOC_SPV::ReadGpio packet(port, pin); + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } void PlocSupervisorHandler::packetToOutBuffer(uint8_t* packetData, size_t fullSize) { - memcpy(commandBuffer, packetData, fullSize); - rawPacket = commandBuffer; - rawPacketLen = fullSize; - nextReplyId = PLOC_SPV::ACK_REPORT; + memcpy(commandBuffer, packetData, fullSize); + rawPacket = commandBuffer; + rawPacketLen = fullSize; + nextReplyId = PLOC_SPV::ACK_REPORT; } void PlocSupervisorHandler::disableAllReplies() { + DeviceReplyMap::iterator iter; - DeviceReplyMap::iterator iter; + /* Disable ack reply */ + iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); - /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); + DeviceCommandId_t commandId = getPendingCommand(); - DeviceCommandId_t commandId = getPendingCommand(); - - /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ - switch (commandId) { + /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ + switch (commandId) { case PLOC_SPV::GET_HK_REPORT: { - iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT); - info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - break; + iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT); + info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + break; } default: { - break; - } + break; } + } - /* We must always disable the execution report reply here */ - disableExeReportReply(); + /* We must always disable the execution report reply here */ + disableExeReportReply(); } void PlocSupervisorHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { + DeviceReplyIter iter = deviceReplyMap.find(replyId); - DeviceReplyIter iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply not in reply map" << std::endl; + return; + } - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply not in reply map" << std::endl; - return; - } + DeviceCommandInfo* info = &(iter->second.command->second); - DeviceCommandInfo* info = &(iter->second.command->second); + if (info == nullptr) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" + << std::endl; + return; + } - if (info == nullptr) { - sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" << std::endl; - return; - } - - if (info->sendReplyTo != NO_COMMANDER) { - actionHelper.finish(false, info->sendReplyTo, iter->first, status); - } - info->isExecuting = false; + if (info->sendReplyTo != NO_COMMANDER) { + actionHelper.finish(false, info->sendReplyTo, iter->first, status); + } + info->isExecuting = false; } void PlocSupervisorHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ - info->command->second.expectedReplies = 1; + DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ + info->command->second.expectedReplies = 1; } -ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, size_t remainingSize, - size_t* foundLen) { - ReturnValue_t result = IGNORE_FULL_PACKET; - uint16_t packetLen = 0; - *foundLen = 0; +ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t* packet, size_t remainingSize, + size_t* foundLen) { + ReturnValue_t result = IGNORE_FULL_PACKET; + uint16_t packetLen = 0; + *foundLen = 0; - for (size_t idx = 0; idx < remainingSize; idx++) { - std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1); - bufferTop += 1; - *foundLen += 1; - if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) { - packetLen = readSpacePacketLength(spacePacketBuffer); - } - - if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { - packetInBuffer = true; - bufferTop = 0; - return checkMramPacketApid(); - } - - if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) { - *foundLen = remainingSize; - disableAllReplies(); - bufferTop = 0; - return MRAM_PACKET_PARSING_FAILURE; - } + for (size_t idx = 0; idx < remainingSize; idx++) { + std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1); + bufferTop += 1; + *foundLen += 1; + if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) { + packetLen = readSpacePacketLength(spacePacketBuffer); } - return result; + if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) { + packetInBuffer = true; + bufferTop = 0; + return checkMramPacketApid(); + } + + if (bufferTop == PLOC_SPV::MAX_PACKET_SIZE) { + *foundLen = remainingSize; + disableAllReplies(); + bufferTop = 0; + return MRAM_PACKET_PARSING_FAILURE; + } + } + + return result; } ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id) { + ReturnValue_t result = RETURN_FAILED; - ReturnValue_t result = RETURN_FAILED; - - // Prepare packet for downlink - if (packetInBuffer) { - uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); - result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; - return result; - } - handleMramDumpFile(id); - if (downlinkMramDump == true) { - handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, - id); - } - packetInBuffer = false; - receivedMramDumpPackets++; - if (expectedMramDumpPackets == receivedMramDumpPackets) { - nextReplyId = PLOC_SPV::EXE_REPORT; - } - increaseExpectedMramReplies(id); - return RETURN_OK; + // Prepare packet for downlink + if (packetInBuffer) { + uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); + result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; + return result; } - return result; + handleMramDumpFile(id); + if (downlinkMramDump == true) { + handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, id); + } + packetInBuffer = false; + receivedMramDumpPackets++; + if (expectedMramDumpPackets == receivedMramDumpPackets) { + nextReplyId = PLOC_SPV::EXE_REPORT; + } + increaseExpectedMramReplies(id); + return RETURN_OK; + } + return result; } void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) { - DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); - DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); - if (mramDumpIter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " - << "in reply map" << std::endl; - return; - } - if (exeReportIter == deviceReplyMap.end()) { - sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Execution report not " - << "in reply map" << std::endl; - return; - } - DeviceReplyInfo *mramReplyInfo = &(mramDumpIter->second); - if (mramReplyInfo == nullptr) { - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: MRAM reply info nullptr" - << std::endl; - return; - } - DeviceReplyInfo *exeReplyInfo = &(exeReportIter->second); - if (exeReplyInfo == nullptr) { - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Execution reply info" - << " nullptr" << std::endl; - return; - } - DeviceCommandInfo* info = &(mramReplyInfo->command->second); - if (info == nullptr){ - sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Command info nullptr" - << std::endl; - return; - } - uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; - if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) - && (sequenceFlags != static_cast(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 { - // Command expects the execution report - info->expectedReplies = 1; - mramReplyInfo->delayCycles = 0; - } + DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); + DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + if (mramDumpIter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " + << "in reply map" << std::endl; return; + } + if (exeReportIter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Execution report not " + << "in reply map" << std::endl; + return; + } + DeviceReplyInfo* mramReplyInfo = &(mramDumpIter->second); + if (mramReplyInfo == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: MRAM reply info nullptr" + << std::endl; + return; + } + DeviceReplyInfo* exeReplyInfo = &(exeReportIter->second); + if (exeReplyInfo == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Execution reply info" + << " nullptr" << std::endl; + return; + } + DeviceCommandInfo* info = &(mramReplyInfo->command->second); + if (info == nullptr) { + sif::debug << "PlocSupervisorHandler::increaseExpectedReplies: Command info nullptr" + << std::endl; + return; + } + uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; + if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) && + (sequenceFlags != static_cast(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 { + // Command expects the execution report + info->expectedReplies = 1; + mramReplyInfo->delayCycles = 0; + } + return; } ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() { - uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK; - if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) { - return NO_MRAM_PACKET; - } - return APERIODIC_REPLY; + uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & PLOC_SPV::APID_MASK; + if (apid != PLOC_SPV::APID_MRAM_DUMP_TM) { + return NO_MRAM_PACKET; + } + return APERIODIC_REPLY; } ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) { - ReturnValue_t result = RETURN_OK; - uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); - uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); - if (id == PLOC_SPV::FIRST_MRAM_DUMP) { - if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) - || (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { - result = createMramDumpFile(); - if (result != RETURN_OK) { - return result; - } - } + ReturnValue_t result = RETURN_OK; + uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); + uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); + if (id == PLOC_SPV::FIRST_MRAM_DUMP) { + if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) || + (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + result = createMramDumpFile(); + if (result != RETURN_OK) { + return result; + } } - if (not std::filesystem::exists(activeMramFile)) { - sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist" - << std::endl; - return MRAM_FILE_NOT_EXISTS; - } - std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); - file.write( - reinterpret_cast(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH), - packetLen - 1); - file.close(); - return RETURN_OK; + } + if (not std::filesystem::exists(activeMramFile)) { + sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist" + << std::endl; + return MRAM_FILE_NOT_EXISTS; + } + std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); + file.write( + reinterpret_cast(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH), + packetLen - 1); + file.close(); + return RETURN_OK; } uint16_t PlocSupervisorHandler::readSpacePacketLength(uint8_t* spacePacket) { - return spacePacket[4] << 8 | spacePacket[5]; + return spacePacket[4] << 8 | spacePacket[5]; } uint8_t PlocSupervisorHandler::readSequenceFlags(uint8_t* spacePacket) { - return spacePacketBuffer[2] >> 6; + return spacePacketBuffer[2] >> 6; } ReturnValue_t PlocSupervisorHandler::createMramDumpFile() { - ReturnValue_t result = RETURN_OK; - std::string timeStamp; - result = getTimeStampString(timeStamp); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = RETURN_OK; + std::string timeStamp; + result = getTimeStampString(timeStamp); + if (result != RETURN_OK) { + return result; + } - std::string filename = "mram-dump--" + timeStamp + ".bin"; + std::string filename = "mram-dump--" + timeStamp + ".bin"; #if BOARD_TE0720 == 0 - std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); + std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); #else - std::string currentMountPrefix("/mnt/sd0"); + std::string currentMountPrefix("/mnt/sd0"); #endif /* BOARD_TE0720 == 0 */ - // Check if path to PLOC directory exists - if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { - sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist" - << std::endl; - return PATH_DOES_NOT_EXIST; - } - activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename; - // Create new file - std::ofstream file(activeMramFile, std::ios_base::out); - file.close(); + // Check if path to PLOC directory exists + if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { + sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist" + << std::endl; + return PATH_DOES_NOT_EXIST; + } + activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename; + // Create new file + std::ofstream file(activeMramFile, std::ios_base::out); + file.close(); - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp) { - Clock::TimeOfDay_t time; - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time" - << 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); - return RETURN_OK; + Clock::TimeOfDay_t time; + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time" + << 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); + return RETURN_OK; } diff --git a/bsp_q7s/devices/PlocSupervisorHandler.h b/bsp_q7s/devices/PlocSupervisorHandler.h index f22c86b1..986e5bbb 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.h +++ b/bsp_q7s/devices/PlocSupervisorHandler.h @@ -1,12 +1,12 @@ #ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ #define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ -#include "devicedefinitions/PlocSupervisorDefinitions.h" #include - #include #include +#include "devicedefinitions/PlocSupervisorDefinitions.h" + /** * @brief This is the device handler for the supervisor of the PLOC which is programmed by * Thales. @@ -19,324 +19,327 @@ * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * @author J. Meier */ -class PlocSupervisorHandler: public DeviceHandlerBase { -public: +class PlocSupervisorHandler : public DeviceHandlerBase { + public: + PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie); + virtual ~PlocSupervisorHandler(); - PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie); - virtual ~PlocSupervisorHandler(); + virtual ReturnValue_t initialize() override; - virtual ReturnValue_t initialize() override; + protected: + void doStartUp() override; + void doShutDown() override; + 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; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, + uint8_t expectedReplies = 1, bool useAlternateId = false, + DeviceCommandId_t alternateReplyID = 0) override; + size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; -protected: - void doStartUp() override; - void doShutDown() override; - 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; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies = 1, bool useAlternateId = false, - DeviceCommandId_t alternateReplyID = 0) override; - size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER; -private: + //! [EXPORT] : [COMMENT] Space Packet received from PLOC supervisor has invalid CRC + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC supervisor + static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received execution failure reply from PLOC supervisor + static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC supervisor + static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Failed to read current system time + 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 + 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. + 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. + 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. + 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) + 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. + 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. + static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF); - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER; - //! [EXPORT] : [COMMENT] Space Packet received from PLOC supervisor has invalid CRC - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC supervisor - static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Received execution failure reply from PLOC supervisor - static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC supervisor - static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Failed to read current system time - 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 - 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. - 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. - 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. - 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) - 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. - 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. - static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF); + //! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet + static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] PLOC supervisor received acknowledgment failure report + static const Event SUPV_ACK_FAILURE = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] PLOC received execution failure report + static const Event SUPV_EXE_FAILURE = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] PLOC supervisor reply has invalid crc + static const Event SUPV_CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER; + static const uint16_t APID_MASK = 0x7FF; + static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; - //! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet - static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] PLOC supervisor received acknowledgment failure report - static const Event SUPV_ACK_FAILURE = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] PLOC received execution failure report - static const Event SUPV_EXE_FAILURE = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] PLOC supervisor reply has invalid crc - static const Event SUPV_CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW); + uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE]; - static const uint16_t APID_MASK = 0x7FF; - static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; + /** + * This variable is used to store the id of the next reply to receive. This is necessary + * because the PLOC sends as reply to each command at least one acknowledgment and execution + * report. + */ + DeviceCommandId_t nextReplyId = PLOC_SPV::NONE; - uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE]; + UartComIF* uartComIf = nullptr; - /** - * This variable is used to store the id of the next reply to receive. This is necessary - * because the PLOC sends as reply to each command at least one acknowledgment and execution - * report. - */ - DeviceCommandId_t nextReplyId = PLOC_SPV::NONE; + PLOC_SPV::HkSet hkset; + PLOC_SPV::BootStatusReport bootStatusReport; + PLOC_SPV::LatchupStatusReport latchupStatusReport; - UartComIF* uartComIf = nullptr; + /** Number of expected replies following the MRAM dump command */ + uint32_t expectedMramDumpPackets = 0; + uint32_t receivedMramDumpPackets = 0; + /** Set to true as soon as a complete space packet is present in the spacePacketBuffer */ + bool packetInBuffer = false; + /** Points to the next free position in the space packet buffer */ + uint16_t bufferTop = 0; - PLOC_SPV::HkSet hkset; - PLOC_SPV::BootStatusReport bootStatusReport; - PLOC_SPV::LatchupStatusReport latchupStatusReport; - - /** Number of expected replies following the MRAM dump command */ - uint32_t expectedMramDumpPackets = 0; - uint32_t receivedMramDumpPackets = 0; - /** Set to true as soon as a complete space packet is present in the spacePacketBuffer */ - bool packetInBuffer = false; - /** Points to the next free position in the space packet buffer */ - uint16_t bufferTop = 0; - - /** This buffer is used to concatenate space packets received in two different read steps */ - uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE]; + /** This buffer is used to concatenate space packets received in two different read steps */ + uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE]; #if BOARD_TE0720 == 0 - SdCardManager* sdcMan = nullptr; + SdCardManager* sdcMan = nullptr; #endif /* BOARD_TE0720 == 0 */ - /** Path to PLOC specific files on SD card */ - std::string plocFilePath = "ploc"; - std::string activeMramFile; + /** Path to PLOC specific files on SD card */ + std::string plocFilePath = "ploc"; + std::string activeMramFile; - /** Setting this variable to true will enable direct downlink of MRAM packets */ - bool downlinkMramDump = false; + /** Setting this variable to true will enable direct downlink of MRAM packets */ + bool downlinkMramDump = false; - /** - * @brief This function checks the crc of the received PLOC reply. - * - * @param start Pointer to the first byte of the reply. - * @param foundLen Pointer to the length of the whole packet. - * - * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. - */ - ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); + /** + * @brief This function checks the crc of the received PLOC reply. + * + * @param start Pointer to the first byte of the reply. + * @param foundLen Pointer to the length of the whole packet. + * + * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. + */ + ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); - /** - * @brief This function handles the acknowledgment report. - * - * @param data Pointer to the data holding the acknowledgment report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleAckReport(const uint8_t* data); + /** + * @brief This function handles the acknowledgment report. + * + * @param data Pointer to the data holding the acknowledgment report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleAckReport(const uint8_t* data); - /** - * @brief This function handles the data of a execution report. - * - * @param data Pointer to the received data packet. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleExecutionReport(const uint8_t* data); + /** + * @brief This function handles the data of a execution report. + * + * @param data Pointer to the received data packet. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleExecutionReport(const uint8_t* data); - /** - * @brief This function handles the housekeeping report. This means verifying the CRC of the - * reply and filling the appropriate dataset. - * - * @param data Pointer to the data buffer holding the housekeeping read report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleHkReport(const uint8_t* data); + /** + * @brief This function handles the housekeeping report. This means verifying the CRC of the + * reply and filling the appropriate dataset. + * + * @param data Pointer to the data buffer holding the housekeeping read report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleHkReport(const uint8_t* data); - /** - * @brief This function calls the function to check the CRC of the received boot status report - * and fills the associated dataset with the boot status information. - */ - ReturnValue_t handleBootStatusReport(const uint8_t* data); + /** + * @brief This function calls the function to check the CRC of the received boot status report + * and fills the associated dataset with the boot status information. + */ + ReturnValue_t handleBootStatusReport(const uint8_t* data); - ReturnValue_t handleLatchupStatusReport(const uint8_t* data); + ReturnValue_t handleLatchupStatusReport(const uint8_t* data); - /** - * @brief Depending on the current active command, this function sets the reply id of the - * next reply after a successful acknowledgment report has been received. This is - * required by the function getNextReplyLength() to identify the length of the next - * reply to read. - */ - void setNextReplyId(); + /** + * @brief Depending on the current active command, this function sets the reply id of the + * next reply after a successful acknowledgment report has been received. This is + * required by the function getNextReplyLength() to identify the length of the next + * reply to read. + */ + void setNextReplyId(); - /** - * @brief This function handles action message replies in case the telemetry has been - * requested by another object. - * - * @param data Pointer to the telemetry data. - * @param dataSize Size of telemetry in bytes. - * @param replyId Id of the reply. This will be added to the ActionMessage. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function handles action message replies in case the telemetry has been + * requested by another object. + * + * @param data Pointer to the telemetry data. + * @param dataSize Size of telemetry in bytes. + * @param replyId Id of the reply. This will be added to the ActionMessage. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - /** - * @brief This function prepares a space packet which does not transport any data in the - * packet data field apart from the crc. - */ - void prepareEmptyCmd(uint16_t apid); + /** + * @brief This function prepares a space packet which does not transport any data in the + * packet data field apart from the crc. + */ + void prepareEmptyCmd(uint16_t apid); - /** - * @brief This function initializes the space packet to select the boot image of the MPSoC. - */ - void prepareSelBootImageCmd(const uint8_t * commandData); + /** + * @brief This function initializes the space packet to select the boot image of the MPSoC. + */ + void prepareSelBootImageCmd(const uint8_t* commandData); - void prepareDisableHk(); + void prepareDisableHk(); - /** - * @brief This function fills the commandBuffer with the data to update the time of the - * PLOC supervisor. - */ - ReturnValue_t prepareSetTimeRefCmd(); + /** + * @brief This function fills the commandBuffer with the data to update the time of the + * PLOC supervisor. + */ + ReturnValue_t prepareSetTimeRefCmd(); - /** - * @brief This function fills the commandBuffer with the data to change the boot timeout - * value in the PLOC supervisor. - */ - void prepareSetBootTimeoutCmd(const uint8_t * commandData); + /** + * @brief This function fills the commandBuffer with the data to change the boot timeout + * value in the PLOC supervisor. + */ + void prepareSetBootTimeoutCmd(const uint8_t* commandData); - void prepareRestartTriesCmd(const uint8_t * commandData); + void prepareRestartTriesCmd(const uint8_t* commandData); - /** - * @brief This function fills the command buffer with the packet to enable or disable the - * watchdogs on the PLOC. - */ - void prepareWatchdogsEnableCmd(const uint8_t * commandData); + /** + * @brief This function fills the command buffer with the packet to enable or disable the + * watchdogs on the PLOC. + */ + void prepareWatchdogsEnableCmd(const uint8_t* commandData); - /** - * @brief This function fills the command buffer with the packet to set the watchdog timer - * of one of the three watchdogs (PS, PL, INT). - */ - ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t * commandData); + /** + * @brief This function fills the command buffer with the packet to set the watchdog timer + * of one of the three watchdogs (PS, PL, INT). + */ + ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData); - ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData, - DeviceCommandId_t deviceCommand); - ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData); - ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData); - void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData); - void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); - void prepareSetAdcThresholdCmd(const uint8_t* commandData); - void prepareEnableNvmsCmd(const uint8_t* commandData); - void prepareSelectNvmCmd(const uint8_t* commandData); - ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); - ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); - ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); - void preparePrintCpuStatsCmd(const uint8_t* commandData); - void prepareSetDbgVerbosityCmd(const uint8_t* commandData); - void prepareSetGpioCmd(const uint8_t* commandData); - void prepareReadGpioCmd(const uint8_t* commandData); + ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData, + DeviceCommandId_t deviceCommand); + ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData); + ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData); + void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData); + void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); + void prepareSetAdcThresholdCmd(const uint8_t* commandData); + void prepareEnableNvmsCmd(const uint8_t* commandData); + void prepareSelectNvmCmd(const uint8_t* commandData); + ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); + ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); + ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); + void preparePrintCpuStatsCmd(const uint8_t* commandData); + void prepareSetDbgVerbosityCmd(const uint8_t* commandData); + void prepareSetGpioCmd(const uint8_t* commandData); + void prepareReadGpioCmd(const uint8_t* commandData); + /** + * @brief Copies the content of a space packet to the command buffer. + */ + void packetToOutBuffer(uint8_t* packetData, size_t fullSize); - /** - * @brief Copies the content of a space packet to the command buffer. - */ - void packetToOutBuffer(uint8_t* packetData, size_t fullSize); + /** + * @brief In case an acknowledgment failure reply has been received this function disables + * all previously enabled commands and resets the exepected replies variable of an + * active command. + */ + void disableAllReplies(); - /** - * @brief In case an acknowledgment failure reply has been received this function disables - * all previously enabled commands and resets the exepected replies variable of an - * active command. - */ - void disableAllReplies(); + /** + * @brief This function sends a failure report if the active action was commanded by an other + * object. + * + * @param replyId The id of the reply which signals a failure. + * @param status A status byte which gives information about the failure type. + */ + void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - /** - * @brief This function sends a failure report if the active action was commanded by an other - * object. - * - * @param replyId The id of the reply which signals a failure. - * @param status A status byte which gives information about the failure type. - */ - void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); + /** + * @brief This function disables the execution report reply. Within this function also the + * the variable expectedReplies of an active command will be set to 0. + */ + void disableExeReportReply(); - /** - * @brief This function disables the execution report reply. Within this function also the - * the variable expectedReplies of an active command will be set to 0. - */ - void disableExeReportReply(); + /** + * @brief Function is called in scanForReply and fills the spacePacketBuffer with the read + * data until a full packet has been received. + */ + ReturnValue_t parseMramPackets(const uint8_t* packet, size_t remainingSize, size_t* foundlen); - /** - * @brief Function is called in scanForReply and fills the spacePacketBuffer with the read - * data until a full packet has been received. - */ - ReturnValue_t parseMramPackets(const uint8_t *packet, size_t remainingSize, size_t* foundlen); + /** + * @brief This function generates the Service 8 packets for the MRAM dump data. + */ + ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); - /** - * @brief This function generates the Service 8 packets for the MRAM dump data. - */ - ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); + /** + * @brief With this function the number of expected replies following an MRAM dump command + * will be increased. This is necessary to release the command in case not all replies + * have been received. + */ + void increaseExpectedMramReplies(DeviceCommandId_t id); - /** - * @brief With this function the number of expected replies following an MRAM dump command - * will be increased. This is necessary to release the command in case not all replies - * have been received. - */ - void increaseExpectedMramReplies(DeviceCommandId_t id); + /** + * @brief Function checks if the packet written to the space packet buffer is really a + * MRAM dump packet. + */ + ReturnValue_t checkMramPacketApid(); - /** - * @brief Function checks if the packet written to the space packet buffer is really a - * MRAM dump packet. - */ - ReturnValue_t checkMramPacketApid(); + /** + * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving + * the first packet. + */ + ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); - /** - * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving - * the first packet. - */ - ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); + /** + * @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer. + * + * @param spacePacket Pointer to the buffer holding the space packet. + * + * @return The value stored in the length field of the data field. + */ + uint16_t readSpacePacketLength(uint8_t* spacePacket); - /** - * @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer. - * - * @param spacePacket Pointer to the buffer holding the space packet. - * - * @return The value stored in the length field of the data field. - */ - uint16_t readSpacePacketLength(uint8_t* spacePacket); + /** + * @brief Extracts the sequence flags from a space packet referenced by the spacePacket + * pointer. + * + * @param spacePacket Pointer to the buffer holding the space packet. + * + * @return uint8_t where the two least significant bits hold the sequence flags. + */ + uint8_t readSequenceFlags(uint8_t* spacePacket); - /** - * @brief Extracts the sequence flags from a space packet referenced by the spacePacket - * pointer. - * - * @param spacePacket Pointer to the buffer holding the space packet. - * - * @return uint8_t where the two least significant bits hold the sequence flags. - */ - uint8_t readSequenceFlags(uint8_t* spacePacket); - - ReturnValue_t createMramDumpFile(); - ReturnValue_t getTimeStampString(std::string& timeStamp); + ReturnValue_t createMramDumpFile(); + ReturnValue_t getTimeStampString(std::string& timeStamp); }; #endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */ diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 592a2c0d..1478fbb8 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -1,405 +1,393 @@ -#include "fsfw/ipc/QueueFactory.h" #include "PlocUpdater.h" -#include #include +#include #include -PlocUpdater::PlocUpdater(object_id_t objectId) : - SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +#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 - sdcMan = SdCardManager::instance(); + sdcMan = SdCardManager::instance(); #endif - ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PlocUpdater::performOperation(uint8_t operationCode) { - readCommandQueue(); - doStateMachine(); - return HasReturnvaluesIF::RETURN_OK; + readCommandQueue(); + doStateMachine(); + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result = RETURN_FAILED; +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) { - return IS_BUSY; - } + if (state != State::IDLE) { + return IS_BUSY; + } - if (size > MAX_PLOC_UPDATE_PATH) { - return NAME_TOO_LONG; - } + if (size > MAX_PLOC_UPDATE_PATH) { + return NAME_TOO_LONG; + } - switch (actionId) { + switch (actionId) { case UPDATE_A_UBOOT: - image = Image::A; - partition = Partition::UBOOT; - break; + image = Image::A; + partition = Partition::UBOOT; + break; case UPDATE_A_BITSTREAM: - image = Image::A; - partition = Partition::BITSTREAM; - break; + image = Image::A; + partition = Partition::BITSTREAM; + break; case UPDATE_A_LINUX: - image = Image::A; - partition = Partition::LINUX_OS; - break; + image = Image::A; + partition = Partition::LINUX_OS; + break; case UPDATE_A_APP_SW: - image = Image::A; - partition = Partition::APP_SW; - break; + image = Image::A; + partition = Partition::APP_SW; + break; case UPDATE_B_UBOOT: - image = Image::B; - partition = Partition::UBOOT; - break; + image = Image::B; + partition = Partition::UBOOT; + break; case UPDATE_B_BITSTREAM: - image = Image::B; - partition = Partition::BITSTREAM; - break; + image = Image::B; + partition = Partition::BITSTREAM; + break; case UPDATE_B_LINUX: - image = Image::B; - partition = Partition::LINUX_OS; - break; + image = Image::B; + partition = Partition::LINUX_OS; + break; case UPDATE_B_APP_SW: - image = Image::B; - partition = Partition::APP_SW; - break; + image = Image::B; + partition = Partition::APP_SW; + break; default: - return INVALID_ACTION_ID; - } + return INVALID_ACTION_ID; + } - result = getImageLocation(data, size); + result = getImageLocation(data, size); - if (result != RETURN_OK) { - return result; - } + if (result != RETURN_OK) { + return result; + } - state = State::UPDATE_AVAILABLE; + state = State::UPDATE_AVAILABLE; - return EXECUTION_FINISHED; + 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; - ReturnValue_t result; + CommandMessage message; + ReturnValue_t result; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - if (result != RETURN_OK) { - continue; - } - result = actionHelper.handleActionMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - - sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format" - << std::endl; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format" + << std::endl; + } } void PlocUpdater::doStateMachine() { - switch (state) { + switch (state) { case State::IDLE: - break; + break; case State::UPDATE_AVAILABLE: - commandUpdateAvailable(); - break; + commandUpdateAvailable(); + break; case State::UPDATE_TRANSFER: - commandUpdatePacket(); - break; + commandUpdatePacket(); + break; case State::UPDATE_VERIFY: - commandUpdateVerify(); - break; + commandUpdateVerify(); + break; case State::COMMAND_EXECUTING: - break; + break; default: - sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl; + break; + } } ReturnValue_t PlocUpdater::checkNameLength(size_t size) { - if (size > MAX_PLOC_UPDATE_PATH) { - return NAME_TOO_LONG; - } - return RETURN_OK; + if (size > MAX_PLOC_UPDATE_PATH) { + return NAME_TOO_LONG; + } + return RETURN_OK; } ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { - ReturnValue_t result = checkNameLength(size); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = checkNameLength(size); + if (result != RETURN_OK) { + return result; + } #if BOARD_TE0720 == 0 - // Check if file is stored on SD card and if associated SD card is mounted - if (std::string(reinterpret_cast(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; - } + // Check if file is stored on SD card and if associated SD card is mounted + if (std::string(reinterpret_cast(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(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 { - //update image not stored on SD card + } else if (std::string(reinterpret_cast(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 { + // update image not stored on SD card + } #endif /* BOARD_TE0720 == 0 */ - updateFile = std::string(reinterpret_cast(data), size); + updateFile = std::string(reinterpret_cast(data), size); - // Check if file exists - if(not std::filesystem::exists(updateFile)) { - return FILE_NOT_EXISTS; - } - return RETURN_OK; + // Check if file exists + if (not std::filesystem::exists(updateFile)) { + return FILE_NOT_EXISTS; + } + 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) { + switch (pendingCommand) { case (PLOC_SPV::UPDATE_AVAILABLE): - state = State::UPDATE_TRANSFER; - break; + state = State::UPDATE_TRANSFER; + break; case (PLOC_SPV::UPDATE_IMAGE_DATA): - if (remainingPackets == 0) { - packetsSent = 0; // Reset packets sent variable for next update sequence - state = State::UPDATE_VERIFY; - } - else { - state = State::UPDATE_TRANSFER; - } - break; + if (remainingPackets == 0) { + packetsSent = 0; // Reset packets sent variable for next update sequence + state = State::UPDATE_VERIFY; + } else { + state = State::UPDATE_TRANSFER; + } + break; case (PLOC_SPV::UPDATE_VERIFY): - triggerEvent(UPDATE_FINISHED); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - break; + triggerEvent(UPDATE_FINISHED); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + break; default: - sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command" - << std::endl; - state = State::IDLE; - break; - } + sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } } -void PlocUpdater::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - switch(pendingCommand) { - case(PLOC_SPV::UPDATE_AVAILABLE): { - triggerEvent(UPDATE_AVAILABLE_FAILED); - break; +void PlocUpdater::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { + switch (pendingCommand) { + case (PLOC_SPV::UPDATE_AVAILABLE): { + triggerEvent(UPDATE_AVAILABLE_FAILED); + break; } - case(PLOC_SPV::UPDATE_IMAGE_DATA): { - triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent); - break; + case (PLOC_SPV::UPDATE_IMAGE_DATA): { + triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent); + break; } - case(PLOC_SPV::UPDATE_VERIFY): { - triggerEvent(UPDATE_VERIFY_FAILED); - break; + case (PLOC_SPV::UPDATE_VERIFY): { + triggerEvent(UPDATE_VERIFY_FAILED); + break; } default: - sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " - << std::endl; - break; - } - state = State::IDLE; + sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " << std::endl; + break; + } + state = State::IDLE; } void PlocUpdater::commandUpdateAvailable() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - if (not std::filesystem::exists(updateFile)) { - triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state)); - state = State::IDLE; - return; - } - - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(0, file.end); - imageSize = static_cast(file.tellg()); - file.close(); - - numOfUpdatePackets = imageSize / MAX_SP_DATA ; - if (imageSize % MAX_SP_DATA) { - numOfUpdatePackets++; - } - - remainingPackets = numOfUpdatePackets; - packetsSent = 0; - - calcImageCrc(); - - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), - static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); - - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - 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; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } - - pendingCommand = PLOC_SPV::UPDATE_AVAILABLE; - state = State::COMMAND_EXECUTING; + if (not std::filesystem::exists(updateFile)) { + triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state)); + state = State::IDLE; return; + } + + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + imageSize = static_cast(file.tellg()); + file.close(); + + numOfUpdatePackets = imageSize / MAX_SP_DATA; + if (imageSize % MAX_SP_DATA) { + numOfUpdatePackets++; + } + + remainingPackets = numOfUpdatePackets; + packetsSent = 0; + + calcImageCrc(); + + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), + static_cast(partition), imageSize, imageCrc, + numOfUpdatePackets); + + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, + 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; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + return; + } + + pendingCommand = PLOC_SPV::UPDATE_AVAILABLE; + state = State::COMMAND_EXECUTING; + return; } void PlocUpdater::commandUpdatePacket() { - ReturnValue_t result = RETURN_OK; - uint16_t payloadLength = 0; + ReturnValue_t result = RETURN_OK; + uint16_t payloadLength = 0; - if (not std::filesystem::exists(updateFile)) { - triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state), packetsSent); - state = State::IDLE; - return; - } + if (not std::filesystem::exists(updateFile)) { + triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast(state), packetsSent); + state = State::IDLE; + return; + } - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(packetsSent * MAX_SP_DATA, file.beg); + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(packetsSent * MAX_SP_DATA, file.beg); - if (remainingPackets == 1) { - payloadLength = imageSize - static_cast(file.tellg()); - } - else { - payloadLength = MAX_SP_DATA; - } + if (remainingPackets == 1) { + payloadLength = imageSize - static_cast(file.tellg()); + } else { + payloadLength = MAX_SP_DATA; + } - PLOC_SPV::UpdatePacket packet(payloadLength); - file.read(reinterpret_cast(packet.getDataFieldPointer()), payloadLength); - file.close(); - // sequence count of first packet is 1 - packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); - if (numOfUpdatePackets > 1) { - adjustSequenceFlags(packet); - } - packet.makeCrc(); + PLOC_SPV::UpdatePacket packet(payloadLength); + file.read(reinterpret_cast(packet.getDataFieldPointer()), payloadLength); + file.close(); + // sequence count of first packet is 1 + packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); + if (numOfUpdatePackets > 1) { + adjustSequenceFlags(packet); + } + packet.makeCrc(); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), packet.getFullSize()); + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, + PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), + packet.getFullSize()); - if (result != RETURN_OK) { - sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" - << " packet to supervisor handler" << std::endl; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } + if (result != RETURN_OK) { + sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" + << " packet to supervisor handler" << std::endl; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; + return; + } - remainingPackets--; - packetsSent++; + remainingPackets--; + packetsSent++; - pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA; - state = State::COMMAND_EXECUTING; + pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA; + state = State::COMMAND_EXECUTING; } void PlocUpdater::commandUpdateVerify() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), - static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), + static_cast(partition), imageSize, imageCrc, + numOfUpdatePackets); - 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; - triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY); - state = State::IDLE; - pendingCommand = PLOC_SPV::NONE; - return; - } - state = State::COMMAND_EXECUTING; - pendingCommand = PLOC_SPV::UPDATE_VERIFY; + 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; + triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY); + state = State::IDLE; + pendingCommand = PLOC_SPV::NONE; return; + } + state = State::COMMAND_EXECUTING; + pendingCommand = PLOC_SPV::UPDATE_VERIFY; + return; } void PlocUpdater::calcImageCrc() { - std::ifstream file(updateFile, std::ifstream::binary); - file.seekg(0, file.end); - uint32_t count; - uint32_t bit; - uint32_t remainder = INITIAL_REMAINDER_32; - char input; - for (count = 0; count < imageSize; count++) { - file.seekg(count, file.beg); - file.read(&input, 1); - remainder ^= (input << 16); - for (bit = 8; bit > 0; --bit) { - if (remainder & TOPBIT_32) { - remainder = (remainder << 1) ^ POLYNOMIAL_32; - } else { - remainder = (remainder << 1); - } - } + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + uint32_t count; + uint32_t bit; + uint32_t remainder = INITIAL_REMAINDER_32; + char input; + for (count = 0; count < imageSize; count++) { + file.seekg(count, file.beg); + file.read(&input, 1); + remainder ^= (input << 16); + for (bit = 8; bit > 0; --bit) { + if (remainder & TOPBIT_32) { + remainder = (remainder << 1) ^ POLYNOMIAL_32; + } else { + remainder = (remainder << 1); + } } - file.close(); - imageCrc = (remainder ^ FINAL_XOR_VALUE_32); + } + file.close(); + imageCrc = (remainder ^ FINAL_XOR_VALUE_32); } void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) { - if (packetsSent == 0) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)); - } - else if (remainingPackets == 1) { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)); - } - else { - packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::CONTINUED_PKT)); - } + if (packetsSent == 0) { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)); + } else if (remainingPackets == 1) { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)); + } else { + packet.setSequenceFlags(static_cast(PLOC_SPV::SequenceFlags::CONTINUED_PKT)); + } } - diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index d016b9e5..bfd86995 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -2,181 +2,170 @@ #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 */ class PlocUpdater : public SystemObject, - public HasActionsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF, - public CommandsActionsIF { -public: + public HasActionsIF, + public ExecutableObjectIF, + 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; + static const ActionId_t UPDATE_A_APP_SW = 3; + static const ActionId_t UPDATE_B_UBOOT = 4; + static const ActionId_t UPDATE_B_BITSTREAM = 5; + static const ActionId_t UPDATE_B_LINUX = 6; + static const ActionId_t UPDATE_B_APP_SW = 7; - static const ActionId_t UPDATE_A_UBOOT = 0; - static const ActionId_t UPDATE_A_BITSTREAM = 1; - static const ActionId_t UPDATE_A_LINUX = 2; - static const ActionId_t UPDATE_A_APP_SW = 3; - static const ActionId_t UPDATE_B_UBOOT = 4; - static const ActionId_t UPDATE_B_BITSTREAM = 5; - static const ActionId_t UPDATE_B_LINUX = 6; - static const ActionId_t UPDATE_B_APP_SW = 7; + PlocUpdater(object_id_t objectId); + virtual ~PlocUpdater(); - PlocUpdater(object_id_t objectId); - virtual ~PlocUpdater(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); - MessageQueueId_t getCommandQueue() const; - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER; -private: + //! [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. + 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); - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_UPDATER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_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. - 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); + //! [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 + 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 + 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) + static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command. + static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] MPSoC update successful completed + static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_UPDATER; + static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; + static const size_t MAX_PLOC_UPDATE_PATH = 50; + static const size_t SD_PREFIX_LENGTH = 8; + // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) + static const size_t MAX_SP_DATA = 1016; - //! [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 - 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 - 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) - static const Event UPDATE_TRANSFER_FAILED = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Supervisor failed to execute the update verify command. - static const Event UPDATE_VERIFY_FAILED = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] MPSoC update successful completed - static const Event UPDATE_FINISHED = MAKE_EVENT(5, severity::INFO); + static const uint32_t TOPBIT_32 = (1 << 31); + static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; + static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; + static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; - static const uint32_t QUEUE_SIZE = config::PLOC_UPDATER_QUEUE_SIZE; - static const size_t MAX_PLOC_UPDATE_PATH = 50; - static const size_t SD_PREFIX_LENGTH = 8; - // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) - static const size_t MAX_SP_DATA = 1016; - - static const uint32_t TOPBIT_32 = (1 << 31); - static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; - static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; - static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; - - MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; #if BOARD_TE0720 == 0 - SdCardManager* sdcMan = nullptr; + SdCardManager* sdcMan = nullptr; #endif - CommandActionHelper commandActionHelper; + CommandActionHelper commandActionHelper; - ActionHelper actionHelper; + ActionHelper actionHelper; - enum class State: uint8_t { - IDLE, - UPDATE_AVAILABLE, - UPDATE_TRANSFER, - UPDATE_VERIFY, - COMMAND_EXECUTING - }; + enum class State : uint8_t { + IDLE, + UPDATE_AVAILABLE, + UPDATE_TRANSFER, + UPDATE_VERIFY, + COMMAND_EXECUTING + }; - State state = State::IDLE; + State state = State::IDLE; - ActionId_t pendingCommand = PLOC_SPV::NONE; + 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; + 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; + Partition partition = Partition::NONE; - uint32_t packetsSent = 0; - uint32_t remainingPackets = 0; - // Number of packets required to transfer the update image - uint32_t numOfUpdatePackets = 0; + uint32_t packetsSent = 0; + uint32_t remainingPackets = 0; + // Number of packets required to transfer the update image + uint32_t numOfUpdatePackets = 0; - std::string updateFile; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; + std::string updateFile; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; - void readCommandQueue(); - void doStateMachine(); + void readCommandQueue(); + void doStateMachine(); - /** - * @brief Extracts the path and name of the update image from the service 8 command data. - */ - ReturnValue_t getImageLocation(const uint8_t* data, size_t size); + /** + * @brief Extracts the path and name of the update image from the service 8 command data. + */ + ReturnValue_t getImageLocation(const uint8_t* data, size_t size); - ReturnValue_t checkNameLength(size_t size); + ReturnValue_t checkNameLength(size_t size); - /** - * @brief Prepares and sends update available command to PLOC supervisor handler. - */ - void commandUpdateAvailable(); + /** + * @brief Prepares and sends update available command to PLOC supervisor handler. + */ + void commandUpdateAvailable(); - /** - * @brief Prepares and sends and update packet to the PLOC supervisor handler. - */ - void commandUpdatePacket(); + /** + * @brief Prepares and sends and update packet to the PLOC supervisor handler. + */ + void commandUpdatePacket(); - /** - * @brief Prepares and sends the update verification packet to the PLOC supervisor handler. - */ - void commandUpdateVerify(); + /** + * @brief Prepares and sends the update verification packet to the PLOC supervisor handler. + */ + void commandUpdateVerify(); - void calcImageCrc(); + void calcImageCrc(); - void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); + void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); }; #endif /* MISSION_DEVICES_PLOCUPDATER_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h index 6e44cf35..00dc9003 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h @@ -3,31 +3,26 @@ #include -class MemoryParams: public SerialLinkedListAdapter { -public: +class MemoryParams : public SerialLinkedListAdapter { + 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) { + setLinks(); + } - /** - * @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) { - setLinks(); - } -private: - - void setLinks() { - setStart(&startAddress); - startAddress.setNext(&endAddress); - } - - SerializeElement startAddress; - SerializeElement endAddress; + private: + void setLinks() { + setStart(&startAddress); + startAddress.setNext(&endAddress); + } + SerializeElement startAddress; + SerializeElement endAddress; }; - - - #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index 0235d281..3fc21441 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -1,12 +1,12 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ -#include +#include +#include #include #include #include -#include -#include +#include namespace PLOC_SPV { @@ -143,7 +143,7 @@ static const uint8_t DATA_FIELD_OFFSET = 6; * Space packet length for fixed size packets. This is the size of the whole packet data * field. For the length field in the space packet this size will be substracted by one. */ -static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field +static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field /** This is the maximum length of a space packet as defined by the TAS ICD */ static const size_t MAX_COMMAND_SIZE = 1024; @@ -153,51 +153,53 @@ static const size_t MAX_PACKET_SIZE = 1024; static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6; -enum class SequenceFlags: uint8_t { - CONTINUED_PKT = 0b00, FIRST_PKT = 0b01, LAST_PKT = 0b10, STANDALONE_PKT = 0b11 +enum class SequenceFlags : uint8_t { + CONTINUED_PKT = 0b00, + FIRST_PKT = 0b01, + LAST_PKT = 0b10, + STANDALONE_PKT = 0b11 }; -enum PoolIds - : lp_id_t { - NUM_TMS, - TEMP_PS, - TEMP_PL, - SOC_STATE, - NVM0_1_STATE, - NVM3_STATE, - MISSION_IO_STATE, - FMC_STATE, - NUM_TCS, - TEMP_SUP, - UPTIME, - CPULOAD, - AVAILABLEHEAP, - BOOT_SIGNAL, - RESET_COUNTER, - BOOT_AFTER_MS, - BOOT_TIMEOUT_MS, - ACTIVE_NVM, - BP0_STATE, - BP1_STATE, - BP2_STATE, +enum PoolIds : lp_id_t { + NUM_TMS, + TEMP_PS, + TEMP_PL, + SOC_STATE, + NVM0_1_STATE, + NVM3_STATE, + MISSION_IO_STATE, + FMC_STATE, + NUM_TCS, + TEMP_SUP, + UPTIME, + CPULOAD, + AVAILABLEHEAP, + BOOT_SIGNAL, + RESET_COUNTER, + BOOT_AFTER_MS, + BOOT_TIMEOUT_MS, + ACTIVE_NVM, + BP0_STATE, + BP1_STATE, + BP2_STATE, - LATCHUP_ID, - CNT0, - CNT1, - CNT2, - CNT3, - CNT4, - CNT5, - CNT6, - LATCHUP_RPT_TIME_SEC, - LATCHUP_RPT_TIME_MIN, - LATCHUP_RPT_TIME_HOUR, - LATCHUP_RPT_TIME_DAY, - LATCHUP_RPT_TIME_MON, - LATCHUP_RPT_TIME_YEAR, - LATCHUP_RPT_TIME_MSEC, - LATCHUP_RPT_TIME_USEC, - LATCHUP_RPT_TIME_IS_SET, + LATCHUP_ID, + CNT0, + CNT1, + CNT2, + CNT3, + CNT4, + CNT5, + CNT6, + LATCHUP_RPT_TIME_SEC, + LATCHUP_RPT_TIME_MIN, + LATCHUP_RPT_TIME_HOUR, + LATCHUP_RPT_TIME_DAY, + LATCHUP_RPT_TIME_MON, + LATCHUP_RPT_TIME_YEAR, + LATCHUP_RPT_TIME_MSEC, + LATCHUP_RPT_TIME_USEC, + LATCHUP_RPT_TIME_IS_SET, }; static const uint8_t HK_SET_ENTRIES = 13; @@ -211,285 +213,273 @@ static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT; /** * @brief With this class a space packet can be created which does not contain any data. */ -class EmptyPacket: public SpacePacket { -public: +class EmptyPacket : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param apid The APID to set in the space packet. + * + * @note Sequence count of empty packet is always 1. + */ + EmptyPacket(uint16_t apid) : SpacePacket(LENGTH_EMPTY_TC - 1, true, apid, 1) { calcCrc(); } - /** - * @brief Constructor - * - * @param apid The APID to set in the space packet. - * - * @note Sequence count of empty packet is always 1. - */ - EmptyPacket(uint16_t apid) : - SpacePacket(LENGTH_EMPTY_TC - 1, true, apid, 1) { - calcCrc(); - } + private: + /** + * @brief CRC calculation which involves only the header in an empty packet + */ + void calcCrc() { + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader)); -private: - - /** - * @brief CRC calculation which involves only the header in an empty packet - */ - void calcCrc() { - - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader)); - - /* Add crc to packet data field of space packet */ - size_t serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the space packet selecting the boot image of * of the MPSoC. */ -class MPSoCBootSelect: public SpacePacket { -public: +class MPSoCBootSelect : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param mem The memory to boot from: NVM0 (0), NVM1 (1) + * @param bp0 Partition pin 0 + * @param bp1 Partition pin 1 + * @param bp2 Partition pin 2 + */ + MPSoCBootSelect(uint8_t mem, uint8_t bp0, uint8_t bp1, uint8_t bp2) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE, DEFAULT_SEQUENCE_COUNT), + mem(mem), + bp0(bp0), + bp1(bp1), + bp2(bp2) { + initPacket(); + } - /** - * @brief Constructor - * - * @param mem The memory to boot from: NVM0 (0), NVM1 (1) - * @param bp0 Partition pin 0 - * @param bp1 Partition pin 1 - * @param bp2 Partition pin 2 - */ - MPSoCBootSelect(uint8_t mem, uint8_t bp0, uint8_t bp1, uint8_t bp2) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE, - DEFAULT_SEQUENCE_COUNT), mem(mem), bp0(bp0), bp1(bp1), bp2(bp2) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint8_t MEM_OFFSET = 0; + static const uint8_t BP0_OFFSET = 1; + static const uint8_t BP1_OFFSET = 2; + static const uint8_t BP2_OFFSET = 3; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t mem = 0; + uint8_t bp0 = 0; + uint8_t bp1 = 0; + uint8_t bp2 = 0; - static const uint8_t MEM_OFFSET = 0; - static const uint8_t BP0_OFFSET = 1; - static const uint8_t BP1_OFFSET = 2; - static const uint8_t BP2_OFFSET = 3; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + void initPacket() { + uint8_t* data_field_start = this->localData.fields.buffer; + std::memcpy(data_field_start + MEM_OFFSET, &mem, sizeof(mem)); + std::memcpy(data_field_start + BP0_OFFSET, &bp0, sizeof(bp0)); + std::memcpy(data_field_start + BP1_OFFSET, &bp1, sizeof(bp1)); + std::memcpy(data_field_start + BP2_OFFSET, &bp2, sizeof(bp2)); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t mem = 0; - uint8_t bp0 = 0; - uint8_t bp1 = 0; - uint8_t bp2 = 0; - - void initPacket() { - uint8_t* data_field_start = this->localData.fields.buffer; - std::memcpy(data_field_start + MEM_OFFSET, &mem, sizeof(mem)); - std::memcpy(data_field_start + BP0_OFFSET, &bp0, sizeof(bp0)); - std::memcpy(data_field_start + BP1_OFFSET, &bp1, sizeof(bp1)); - std::memcpy(data_field_start + BP2_OFFSET, &bp2, sizeof(bp2)); - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - - /* Add crc to packet data field of space packet */ - size_t serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class generates the space packet to update the time of the PLOC supervisor. */ -class SetTimeRef: public SpacePacket { -public: +class SetTimeRef : public SpacePacket { + public: + SetTimeRef(Clock::TimeOfDay_t* time) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) { + initPacket(time); + } - SetTimeRef(Clock::TimeOfDay_t* time) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) { - initPacket(time); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 34; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; -private: - - static const uint16_t DATA_FIELD_LENGTH = 34; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - void initPacket(Clock::TimeOfDay_t* time) { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&time->second, &data_field_ptr, &serializedSize, - sizeof(time->second), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->minute, &data_field_ptr, &serializedSize, - sizeof(time->minute), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->hour, &data_field_ptr, &serializedSize, - sizeof(time->hour), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->day, &data_field_ptr, &serializedSize, - sizeof(time->day), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->month, &data_field_ptr, &serializedSize, - sizeof(time->month), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&time->year, &data_field_ptr, &serializedSize, - sizeof(time->year), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint32_t milliseconds = time->usecond / 1000; - SerializeAdapter::serialize(&milliseconds, &data_field_ptr, &serializedSize, - sizeof(milliseconds), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint32_t isSet = 0xFFFFFFFF; - SerializeAdapter::serialize(&isSet, &data_field_ptr, &serializedSize, - sizeof(isSet), SerializeIF::Endianness::BIG); - serializedSize = 0; - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket(Clock::TimeOfDay_t* time) { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&time->second, &data_field_ptr, &serializedSize, + sizeof(time->second), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->minute, &data_field_ptr, &serializedSize, + sizeof(time->minute), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->hour, &data_field_ptr, &serializedSize, + sizeof(time->hour), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->day, &data_field_ptr, &serializedSize, + sizeof(time->day), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->month, &data_field_ptr, &serializedSize, + sizeof(time->month), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->year, &data_field_ptr, &serializedSize, + sizeof(time->year), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t milliseconds = time->usecond / 1000; + SerializeAdapter::serialize(&milliseconds, &data_field_ptr, &serializedSize, + sizeof(milliseconds), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t isSet = 0xFFFFFFFF; + SerializeAdapter::serialize(&isSet, &data_field_ptr, &serializedSize, sizeof(isSet), + SerializeIF::Endianness::BIG); + serializedSize = 0; + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the set boot timout command. */ -class SetBootTimeout: public SpacePacket { -public: +class SetBootTimeout : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param timeout The boot timeout in milliseconds. + */ + SetBootTimeout(uint32_t timeout) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) { + initPacket(); + } - /** - * @brief Constructor - * - * @param timeout The boot timeout in milliseconds. - */ - SetBootTimeout(uint32_t timeout) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) { - initPacket(); - } + private: + uint32_t timeout = 0; -private: + /** boot timeout value (uint32_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 6; - uint32_t timeout = 0; - - /** boot timeout value (uint32_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 6; - - void initPacket() { - - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - /* Add crc to packet data field of space packet */ - serializedSize = 0; - SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, + sizeof(timeout), SerializeIF::Endianness::BIG); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + /* Add crc to packet data field of space packet */ + serializedSize = 0; + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class can be used to generate the space packet to set the maximum boot tries. */ -class SetRestartTries: public SpacePacket { -public: +class SetRestartTries : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param restartTries Maximum restart tries to set. + */ + SetRestartTries(uint8_t restartTries) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1), + restartTries(restartTries) { + initPacket(); + } - /** - * @brief Constructor - * - * @param restartTries Maximum restart tries to set. - */ - SetRestartTries(uint8_t restartTries) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1), restartTries( - restartTries) { - initPacket(); - } + private: + uint8_t restartTries = 0; -private: + /** Restart tries value (uint8_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 3; - uint8_t restartTries = 0; - - /** Restart tries value (uint8_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 3; - - void initPacket() { - uint8_t* data_field_ptr = this->localData.fields.buffer; - *data_field_ptr = restartTries; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - size_t serializedSize = 0; - uint8_t* crcPtr = data_field_ptr + 1; - SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + *data_field_ptr = restartTries; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + size_t serializedSize = 0; + uint8_t* crcPtr = data_field_ptr + 1; + SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to notify the supervisor that a new update for the * MPSoC is available. */ -class UpdateAvailable: public SpacePacket { -public: +class UpdateAvailable : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param imageSelect + * @param imagePartition + * @param imageSize + * @param imageCrc + * @param numberOfPackets + */ + UpdateAvailable(uint8_t imageSelect, uint8_t imagePartition, uint32_t imageSize, + uint32_t imageCrc, uint32_t numberOfPackets) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_UPDATE_AVAILABLE, DEFAULT_SEQUENCE_COUNT), + imageSelect(imageSelect), + imagePartition(imagePartition), + imageSize(imageSize), + imageCrc(imageCrc), + numberOfPackets(numberOfPackets) { + initPacket(); + } - /** - * @brief Constructor - * - * @param imageSelect - * @param imagePartition - * @param imageSize - * @param imageCrc - * @param numberOfPackets - */ - UpdateAvailable(uint8_t imageSelect, uint8_t imagePartition, uint32_t imageSize, - uint32_t imageCrc, uint32_t numberOfPackets) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_UPDATE_AVAILABLE, - DEFAULT_SEQUENCE_COUNT), imageSelect(imageSelect), imagePartition( - imagePartition), imageSize(imageSize), imageCrc(imageCrc), numberOfPackets( - numberOfPackets) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 16; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 16; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t imageSelect = 0; + uint8_t imagePartition = 0; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; + uint32_t numberOfPackets = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t imageSelect = 0; - uint8_t imagePartition = 0; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; - uint32_t numberOfPackets = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&imageSelect, &data_field_ptr, &serializedSize, - sizeof(imageSelect), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imagePartition, &data_field_ptr, &serializedSize, - sizeof(imagePartition), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, - sizeof(imageSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, - sizeof(imageCrc), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&numberOfPackets, &data_field_ptr, &serializedSize, - sizeof(numberOfPackets), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&imageSelect, &data_field_ptr, &serializedSize, + sizeof(imageSelect), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imagePartition, &data_field_ptr, &serializedSize, + sizeof(imagePartition), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, + sizeof(imageSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, + sizeof(imageCrc), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&numberOfPackets, &data_field_ptr, &serializedSize, + sizeof(numberOfPackets), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -497,130 +487,126 @@ private: * of housekeeping data. Normally, this will be disabled by default. However, adding this * command can be useful for debugging. */ -class DisablePeriodicHkTransmission: public SpacePacket { -public: +class DisablePeriodicHkTransmission : public SpacePacket { + public: + /** + * @brief Constructor + */ + DisablePeriodicHkTransmission() : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) { + initPacket(); + } - /** - * @brief Constructor - */ - DisablePeriodicHkTransmission() : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) { - initPacket(); - } + private: + uint8_t disableHk = 0; -private: + /** Restart tries value (uint8_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 3; - uint8_t disableHk = 0; - - /** Restart tries value (uint8_t) and crc (uint16_t) */ - static const uint16_t DATA_FIELD_LENGTH = 3; - - void initPacket() { - uint8_t* data_field_ptr = this->localData.fields.buffer; - *data_field_ptr = disableHk; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - size_t serializedSize = 0; - uint8_t* crcPtr = data_field_ptr + 1; - SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + *data_field_ptr = disableHk; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + size_t serializedSize = 0; + uint8_t* crcPtr = data_field_ptr + 1; + SerializeAdapter::serialize(&crc, &crcPtr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to enable the watchdogs of the PLOC. */ -class WatchdogsEnable: public SpacePacket { -public: +class WatchdogsEnable : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param watchdogPs Enables processing system watchdog + * @param watchdogPl Enables programmable logic wathdog + * @param watchdogInt + */ + WatchdogsEnable(uint8_t watchdogPs, uint8_t watchdogPl, uint8_t watchdogInt) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_ENABLE, DEFAULT_SEQUENCE_COUNT), + watchdogPs(watchdogPs), + watchdogPl(watchdogPl), + watchdogInt(watchdogInt) { + initPacket(); + } - /** - * @brief Constructor - * - * @param watchdogPs Enables processing system watchdog - * @param watchdogPl Enables programmable logic wathdog - * @param watchdogInt - */ - WatchdogsEnable(uint8_t watchdogPs, uint8_t watchdogPl, uint8_t watchdogInt) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_ENABLE, DEFAULT_SEQUENCE_COUNT), - watchdogPs(watchdogPs), watchdogPl(watchdogPl), watchdogInt(watchdogInt) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t watchdogPs = 0; + uint8_t watchdogPl = 0; + uint8_t watchdogInt = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t watchdogPs = 0; - uint8_t watchdogPl = 0; - uint8_t watchdogInt = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&watchdogPs, &data_field_ptr, &serializedSize, - sizeof(watchdogPs), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&watchdogPl, &data_field_ptr, &serializedSize, - sizeof(watchdogPl), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&watchdogInt, &data_field_ptr, &serializedSize, - sizeof(watchdogInt), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&watchdogPs, &data_field_ptr, &serializedSize, + sizeof(watchdogPs), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&watchdogPl, &data_field_ptr, &serializedSize, + sizeof(watchdogPl), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&watchdogInt, &data_field_ptr, &serializedSize, + sizeof(watchdogInt), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to set the timeout of one of the three watchdogs (PS, * PL, INT) */ -class WatchdogsConfigTimeout: public SpacePacket { -public: +class WatchdogsConfigTimeout : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param watchdogPs Selects the watchdog to configure (0 - PS, 1 - PL, 2 - INT) + * @param timeout The timeout to set + */ + WatchdogsConfigTimeout(uint8_t watchdog, uint32_t timeout) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_CONFIG_TIMEOUT, DEFAULT_SEQUENCE_COUNT), + watchdog(watchdog), + timeout(timeout) { + initPacket(); + } - /** - * @brief Constructor - * - * @param watchdogPs Selects the watchdog to configure (0 - PS, 1 - PL, 2 - INT) - * @param timeout The timeout to set - */ - WatchdogsConfigTimeout(uint8_t watchdog, uint32_t timeout) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_CONFIG_TIMEOUT, - DEFAULT_SEQUENCE_COUNT), watchdog(watchdog), timeout(timeout) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t watchdog = 0; + uint32_t timeout = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t watchdog = 0; - uint32_t timeout = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&watchdog, &data_field_ptr, &serializedSize, - sizeof(watchdog), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&watchdog, &data_field_ptr, &serializedSize, + sizeof(watchdog), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, + sizeof(timeout), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -628,723 +614,693 @@ private: * * @details There are 7 different latchup alerts. */ -class LatchupAlert: public SpacePacket { -public: - - /** - * @brief Constructor - * - * @param state true - enable, false - disable - * @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - */ - LatchupAlert(bool state, uint8_t latchupId) : - SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) { - if (state) { - this->setAPID(APID_ENABLE_LATCHUP_ALERT); - } else { - this->setAPID(APID_DISABLE_LATCHUP_ALERT); - } - this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT); - initPacket(); +class LatchupAlert : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param state true - enable, false - disable + * @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + */ + LatchupAlert(bool state, uint8_t latchupId) + : SpacePacket(DATA_FIELD_LENGTH - 1, true), latchupId(latchupId) { + if (state) { + this->setAPID(APID_ENABLE_LATCHUP_ALERT); + } else { + this->setAPID(APID_DISABLE_LATCHUP_ALERT); } + this->setPacketSequenceCount(DEFAULT_SEQUENCE_COUNT); + initPacket(); + } -private: + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + uint8_t latchupId = 0; - uint8_t latchupId = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the command to calibrate a certain latchup alert. */ -class AutoCalibrateAlert: public SpacePacket { -public: +class AutoCalibrateAlert : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param mg + */ + AutoCalibrateAlert(uint8_t latchupId, uint32_t mg) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_AUTO_CALIBRATE_ALERT, DEFAULT_SEQUENCE_COUNT), + latchupId(latchupId), + mg(mg) { + initPacket(); + } - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param mg - */ - AutoCalibrateAlert(uint8_t latchupId, uint32_t mg) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_AUTO_CALIBRATE_ALERT, - DEFAULT_SEQUENCE_COUNT), latchupId(latchupId), mg(mg) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t latchupId = 0; + uint32_t mg = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint32_t mg = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&mg, &data_field_ptr, &serializedSize, - sizeof(mg), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&mg, &data_field_ptr, &serializedSize, sizeof(mg), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; +class SetAlertlimit : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param dutycycle + */ + SetAlertlimit(uint8_t latchupId, uint32_t dutycycle) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, DEFAULT_SEQUENCE_COUNT), + latchupId(latchupId), + dutycycle(dutycycle) { + initPacket(); + } -class SetAlertlimit: public SpacePacket { -public: + private: + static const uint16_t DATA_FIELD_LENGTH = 7; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param dutycycle - */ - SetAlertlimit(uint8_t latchupId, uint32_t dutycycle) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_LIMIT, - DEFAULT_SEQUENCE_COUNT), latchupId(latchupId), dutycycle(dutycycle) { - initPacket(); - } + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; -private: + uint8_t latchupId = 0; + uint32_t dutycycle = 0; - static const uint16_t DATA_FIELD_LENGTH = 7; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint32_t dutycycle = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&dutycycle, &data_field_ptr, &serializedSize, - sizeof(dutycycle), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&dutycycle, &data_field_ptr, &serializedSize, + sizeof(dutycycle), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; -class SetAlertIrqFilter: public SpacePacket { -public: +class SetAlertIrqFilter : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, + * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) + * @param tp + * @param div + */ + SetAlertIrqFilter(uint8_t latchupId, uint8_t tp, uint8_t div) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_IRQ_FILTER, DEFAULT_SEQUENCE_COUNT), + tp(tp), + div(div) { + initPacket(); + } - /** - * @brief Constructor - * - * @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC, - * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) - * @param tp - * @param div - */ - SetAlertIrqFilter(uint8_t latchupId, uint8_t tp, uint8_t div) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_IRQ_FILTER, - DEFAULT_SEQUENCE_COUNT), tp(tp), div(div) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t latchupId = 0; + uint8_t tp = 0; + uint8_t div = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t latchupId = 0; - uint8_t tp = 0; - uint8_t div = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, - sizeof(latchupId), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&tp, &data_field_ptr, &serializedSize, - sizeof(tp), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&div, &data_field_ptr, &serializedSize, - sizeof(div), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&latchupId, &data_field_ptr, &serializedSize, + sizeof(latchupId), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&tp, &data_field_ptr, &serializedSize, sizeof(tp), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&div, &data_field_ptr, &serializedSize, sizeof(div), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; - /** * @brief This class packages the space packet to set the sweep period of the ADC. */ -class SetAdcSweepPeriod: public SpacePacket { -public: +class SetAdcSweepPeriod : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param sweepPeriod Sweep period in us. minimum is 21 us + */ + SetAdcSweepPeriod(uint32_t sweepPeriod) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_SWEEP_PERIOD, DEFAULT_SEQUENCE_COUNT), + sweepPeriod(sweepPeriod) { + initPacket(); + } - /** - * @brief Constructor - * - * @param sweepPeriod Sweep period in us. minimum is 21 us - */ - SetAdcSweepPeriod(uint32_t sweepPeriod) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_SWEEP_PERIOD, - DEFAULT_SEQUENCE_COUNT), sweepPeriod(sweepPeriod) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint32_t sweepPeriod = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint32_t sweepPeriod = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&sweepPeriod, &data_field_ptr, &serializedSize, - sizeof(sweepPeriod), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&sweepPeriod, &data_field_ptr, &serializedSize, + sizeof(sweepPeriod), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to enable or disable ADC channels. */ -class SetAdcEnabledChannels: public SpacePacket { -public: +class SetAdcEnabledChannels : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param ch Defines channels to be enabled or disabled. + */ + SetAdcEnabledChannels(uint16_t ch) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS, + DEFAULT_SEQUENCE_COUNT), + ch(ch) { + initPacket(); + } - /** - * @brief Constructor - * - * @param ch Defines channels to be enabled or disabled. - */ - SetAdcEnabledChannels(uint16_t ch) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_ENABLED_CHANNELS, - DEFAULT_SEQUENCE_COUNT), ch(ch) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint16_t ch = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint16_t ch = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&ch, &data_field_ptr, &serializedSize, - sizeof(ch), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&ch, &data_field_ptr, &serializedSize, sizeof(ch), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to configures the window size and striding step of * the moving average filter applied to the ADC readings. */ -class SetAdcWindowAndStride: public SpacePacket { -public: +class SetAdcWindowAndStride : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param windowSize + * @param stridingStepSize + */ + SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE, + DEFAULT_SEQUENCE_COUNT), + windowSize(windowSize), + stridingStepSize(stridingStepSize) { + initPacket(); + } - /** - * @brief Constructor - * - * @param windowSize - * @param stridingStepSize - */ - SetAdcWindowAndStride(uint16_t windowSize, uint16_t stridingStepSize) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_WINDOW_AND_STRIDE, - DEFAULT_SEQUENCE_COUNT), windowSize(windowSize), stridingStepSize( - stridingStepSize) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint16_t windowSize = 0; + uint16_t stridingStepSize = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint16_t windowSize = 0; - uint16_t stridingStepSize = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&windowSize, &data_field_ptr, &serializedSize, - sizeof(windowSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&stridingStepSize, &data_field_ptr, &serializedSize, - sizeof(stridingStepSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&windowSize, &data_field_ptr, &serializedSize, + sizeof(windowSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&stridingStepSize, &data_field_ptr, &serializedSize, + sizeof(stridingStepSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to set the ADC trigger threshold. */ -class SetAdcThreshold: public SpacePacket { -public: +class SetAdcThreshold : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param threshold + */ + SetAdcThreshold(uint32_t threshold) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, DEFAULT_SEQUENCE_COUNT), + threshold(threshold) { + initPacket(); + } - /** - * @brief Constructor - * - * @param threshold - */ - SetAdcThreshold(uint32_t threshold) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_THRESHOLD, - DEFAULT_SEQUENCE_COUNT), threshold(threshold) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint32_t threshold = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint32_t threshold = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&threshold, &data_field_ptr, &serializedSize, - sizeof(threshold), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&threshold, &data_field_ptr, &serializedSize, + sizeof(threshold), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to select between NVM 0 and NVM 1. */ -class SelectNvm: public SpacePacket { -public: +class SelectNvm : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param mem 0 - select NVM0, 1 - select NVM1. + */ + SelectNvm(uint8_t mem) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM, DEFAULT_SEQUENCE_COUNT), + mem(mem) { + initPacket(); + } - /** - * @brief Constructor - * - * @param mem 0 - select NVM0, 1 - select NVM1. - */ - SelectNvm(uint8_t mem) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM, - DEFAULT_SEQUENCE_COUNT), mem(mem) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t mem = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t mem = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&mem, &data_field_ptr, &serializedSize, - sizeof(mem), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&mem, &data_field_ptr, &serializedSize, sizeof(mem), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to power the NVMs on or off. */ -class EnableNvms: public SpacePacket { -public: +class EnableNvms : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory. + * @param n3 Set to one to power NVM3 on. 0 powers off the memory. + */ + EnableNvms(uint8_t n01, uint8_t n3) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT), + n01(n01), + n3(n3) { + initPacket(); + } - /** - * @brief Constructor - * - * @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory. - * @param n3 Set to one to power NVM3 on. 0 powers off the memory. - */ - EnableNvms(uint8_t n01, uint8_t n3) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, - DEFAULT_SEQUENCE_COUNT), n01(n01), n3(n3) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t n01 = 0; + uint8_t n3 = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t n01 = 0; - uint8_t n3 = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&n01, &data_field_ptr, &serializedSize, - sizeof(n01), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&n3, &data_field_ptr, &serializedSize, - sizeof(n3), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&n01, &data_field_ptr, &serializedSize, sizeof(n01), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&n3, &data_field_ptr, &serializedSize, sizeof(n3), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to run auto EM tests. */ -class RunAutoEmTests: public SpacePacket { -public: +class RunAutoEmTests : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) + */ + RunAutoEmTests(uint8_t test) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, DEFAULT_SEQUENCE_COUNT), + test(test) { + initPacket(); + } - /** - * @brief Constructor - * - * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) - */ - RunAutoEmTests(uint8_t test) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_RUN_AUTO_EM_TESTS, - DEFAULT_SEQUENCE_COUNT), test(test) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t test = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t test = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&test, &data_field_ptr, &serializedSize, - sizeof(test), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&test, &data_field_ptr, &serializedSize, sizeof(test), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet causing the supervisor to print the CPU load to * the debug output. */ -class PrintCpuStats: public SpacePacket { -public: +class PrintCpuStats : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param en Print is enabled if en != 0 + */ + PrintCpuStats(uint8_t en) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_PRINT_CPU_STATS, DEFAULT_SEQUENCE_COUNT), + en(en) { + initPacket(); + } - /** - * @brief Constructor - * - * @param en Print is enabled if en != 0 - */ - PrintCpuStats(uint8_t en) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_PRINT_CPU_STATS, - DEFAULT_SEQUENCE_COUNT), en(en) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t en = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t en = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&en, &data_field_ptr, &serializedSize, - sizeof(en), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&en, &data_field_ptr, &serializedSize, sizeof(en), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet to set the print verbosity in the supervisor * software. */ -class SetDbgVerbosity: public SpacePacket { -public: +class SetDbgVerbosity : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param vb 0: None, 1: Error, 2: Warn, 3: Info + */ + SetDbgVerbosity(uint8_t vb) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_DBG_VERBOSITY, DEFAULT_SEQUENCE_COUNT), + vb(vb) { + initPacket(); + } - /** - * @brief Constructor - * - * @param vb 0: None, 1: Error, 2: Warn, 3: Info - */ - SetDbgVerbosity(uint8_t vb) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_DBG_VERBOSITY, - DEFAULT_SEQUENCE_COUNT), vb(vb) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 3; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 3; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t vb = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t vb = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&vb, &data_field_ptr, &serializedSize, - sizeof(vb), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&vb, &data_field_ptr, &serializedSize, sizeof(vb), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; - /** * @brief This class packages the space packet to wipe or dump parts of the MRAM. */ -class MramCmd: public SpacePacket { -public: +class MramCmd : public SpacePacket { + public: + enum class MramAction { WIPE, DUMP }; - enum class MramAction { - WIPE, - DUMP - }; - - /** - * @brief Constructor - * - * @param start Start address of the MRAM section to wipe or dump - * @param stop End address of the MRAM section to wipe or dump - * @param action Dump or wipe MRAM - * - * @note The content at the stop address is excluded from the dump or wipe operation. - */ - MramCmd(uint32_t start, uint32_t stop, MramAction action) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_IDLE_PACKET, - DEFAULT_SEQUENCE_COUNT), start(start), stop(stop) { - if(action == MramAction::WIPE) { - this->setAPID(APID_WIPE_MRAM); - } - else if (action == MramAction::DUMP) { - this->setAPID(APID_DUMP_MRAM); - } - else { - sif::debug << "WipeMram: Invalid action specified"; - } - initPacket(); + /** + * @brief Constructor + * + * @param start Start address of the MRAM section to wipe or dump + * @param stop End address of the MRAM section to wipe or dump + * @param action Dump or wipe MRAM + * + * @note The content at the stop address is excluded from the dump or wipe operation. + */ + MramCmd(uint32_t start, uint32_t stop, MramAction action) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_IDLE_PACKET, DEFAULT_SEQUENCE_COUNT), + start(start), + stop(stop) { + if (action == MramAction::WIPE) { + this->setAPID(APID_WIPE_MRAM); + } else if (action == MramAction::DUMP) { + this->setAPID(APID_DUMP_MRAM); + } else { + sif::debug << "WipeMram: Invalid action specified"; } + initPacket(); + } -private: + private: + static const uint16_t DATA_FIELD_LENGTH = 8; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - static const uint16_t DATA_FIELD_LENGTH = 8; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + uint32_t start = 0; + uint32_t stop = 0; - uint32_t start = 0; - uint32_t stop = 0; - - void initPacket() { - uint8_t concatBuffer[6]; - concatBuffer[0] = static_cast(start >> 16); - concatBuffer[1] = static_cast(start >> 8); - concatBuffer[2] = static_cast(start); - concatBuffer[3] = static_cast(stop >> 16); - concatBuffer[4] = static_cast(stop >> 8); - concatBuffer[5] = static_cast(stop); - uint8_t* data_field_ptr = this->localData.fields.buffer; - std::memcpy(data_field_ptr, concatBuffer, sizeof(concatBuffer)); - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + uint8_t concatBuffer[6]; + concatBuffer[0] = static_cast(start >> 16); + concatBuffer[1] = static_cast(start >> 8); + concatBuffer[2] = static_cast(start); + concatBuffer[3] = static_cast(stop >> 16); + concatBuffer[4] = static_cast(stop >> 8); + concatBuffer[5] = static_cast(stop); + uint8_t* data_field_ptr = this->localData.fields.buffer; + std::memcpy(data_field_ptr, concatBuffer, sizeof(concatBuffer)); + size_t serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet change the state of a GPIO. This command is only * required for ground testing. */ -class SetGpio: public SpacePacket { -public: +class SetGpio : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param port + * @param pin + * @param val + */ + SetGpio(uint8_t port, uint8_t pin, uint8_t val) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_GPIO, DEFAULT_SEQUENCE_COUNT), + port(port), + pin(pin), + val(val) { + initPacket(); + } - /** - * @brief Constructor - * - * @param port - * @param pin - * @param val - */ - SetGpio(uint8_t port, uint8_t pin, uint8_t val) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_GPIO, - DEFAULT_SEQUENCE_COUNT), port(port), pin(pin), val(val) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 5; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 5; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t port = 0; + uint8_t pin = 0; + uint8_t val = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t port = 0; - uint8_t pin = 0; - uint8_t val = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, - sizeof(port), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, - sizeof(pin), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&val, &data_field_ptr, &serializedSize, - sizeof(val), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, sizeof(port), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, sizeof(pin), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&val, &data_field_ptr, &serializedSize, sizeof(val), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet causing the supervisor print the state of a GPIO * to the debug output. */ -class ReadGpio: public SpacePacket { -public: +class ReadGpio : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param port + * @param pin + */ + ReadGpio(uint8_t port, uint8_t pin) + : SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_READ_GPIO, DEFAULT_SEQUENCE_COUNT), + port(port), + pin(pin) { + initPacket(); + } - /** - * @brief Constructor - * - * @param port - * @param pin - */ - ReadGpio(uint8_t port, uint8_t pin) : - SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_READ_GPIO, - DEFAULT_SEQUENCE_COUNT), port(port), pin(pin) { - initPacket(); - } + private: + static const uint16_t DATA_FIELD_LENGTH = 4; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; -private: + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - static const uint16_t DATA_FIELD_LENGTH = 4; - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + uint8_t port = 0; + uint8_t pin = 0; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; - - uint8_t port = 0; - uint8_t pin = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, - sizeof(port), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, - sizeof(pin), SerializeIF::Endianness::BIG); - serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&port, &data_field_ptr, &serializedSize, sizeof(port), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&pin, &data_field_ptr, &serializedSize, sizeof(pin), + SerializeIF::Endianness::BIG); + serializedSize = 0; + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; /** @@ -1355,255 +1311,236 @@ private: * OP = 0x01: Only the mirror entries will be wiped. * OP = 0x02: Only the circular entries will be wiped. */ -class FactoryReset: public SpacePacket { -public: +class FactoryReset : public SpacePacket { + public: + enum class Op { CLEAR_ALL, MIRROR_ENTRIES, CIRCULAR_ENTRIES }; - enum class Op { - CLEAR_ALL, - MIRROR_ENTRIES, - CIRCULAR_ENTRIES - }; + /** + * @brief Constructor + * + * @param op + */ + FactoryReset(Op op) : SpacePacket(0, true, APID_FACTORY_RESET, DEFAULT_SEQUENCE_COUNT), op(op) { + initPacket(); + } - /** - * @brief Constructor - * - * @param op - */ - FactoryReset(Op op) : - SpacePacket(0, true, APID_FACTORY_RESET, - DEFAULT_SEQUENCE_COUNT), op(op) { - initPacket(); - } - -private: - - uint16_t packetLen = 1; // only CRC in data field - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - - uint8_t crcOffset = 0; - - Op op = Op::CLEAR_ALL; - - void initPacket() { - - uint8_t* data_field_ptr = this->localData.fields.buffer; - - switch(op) { - case Op::MIRROR_ENTRIES: - *data_field_ptr = 1; - packetLen = 2; - crcOffset = 1; - break; - case Op::CIRCULAR_ENTRIES: - *data_field_ptr = 2; - packetLen = 2; - crcOffset = 1; - break; - default: - break; - } - this->setPacketDataLength(packetLen); - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + packetLen - 1); - uint8_t* crcPos = this->localData.fields.buffer + crcOffset; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); + private: + uint16_t packetLen = 1; // only CRC in data field + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + + uint8_t crcOffset = 0; + + Op op = Op::CLEAR_ALL; + + void initPacket() { + uint8_t* data_field_ptr = this->localData.fields.buffer; + + switch (op) { + case Op::MIRROR_ENTRIES: + *data_field_ptr = 1; + packetLen = 2; + crcOffset = 1; + break; + case Op::CIRCULAR_ENTRIES: + *data_field_ptr = 2; + packetLen = 2; + crcOffset = 1; + break; + default: + break; } + this->setPacketDataLength(packetLen); + size_t serializedSize = 0; + uint16_t crc = + CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + packetLen - 1); + uint8_t* crcPos = this->localData.fields.buffer + crcOffset; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } }; class SupvTcSpacePacket : public SpacePacket { -public: - SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid) : - SpacePacket(payloadDataLen + 1, true, apid, - DEFAULT_SEQUENCE_COUNT), payloadDataLen(payloadDataLen) { - } + public: + SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid) + : SpacePacket(payloadDataLen + 1, true, apid, DEFAULT_SEQUENCE_COUNT), + payloadDataLen(payloadDataLen) {} - void makeCrc() { - size_t serializedSize = 0; - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + payloadDataLen); - uint8_t* crcPos = this->localData.fields.buffer + payloadDataLen; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } + void makeCrc() { + size_t serializedSize = 0; + uint16_t crc = + CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + payloadDataLen); + uint8_t* crcPos = this->localData.fields.buffer + payloadDataLen; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } -private: - // The sequence count of most of the TC packets for the supervisor is 1. - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + private: + // The sequence count of most of the TC packets for the supervisor is 1. + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - // The size of the payload data (data field without crc size) - size_t payloadDataLen = 0; + // The size of the payload data (data field without crc size) + size_t payloadDataLen = 0; }; /** * @brief This class can be used to package the update available or update verify command. */ -class UpdateInfo: public SupvTcSpacePacket { -public: +class UpdateInfo : public SupvTcSpacePacket { + public: + /** + * @brief Constructor + * + * @param apid Packet can be used to generate the update available and the update verify + * packet. Thus the APID must be specified here. + * @param image The image to update on a NVM (A - 0, B - 1) + * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, + * application - 4 + * @param imageSize The size of the update image + * param numPackets The number of space packets required to transfer all data. + */ + UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, uint32_t imageCrc, + uint32_t numPackets) + : SupvTcSpacePacket(PAYLOAD_LENGTH, apid), + image(image), + partition(partition), + imageSize(imageSize), + imageCrc(imageCrc), + numPackets(numPackets) { + initPacket(); + makeCrc(); + } - /** - * @brief Constructor - * - * @param apid Packet can be used to generate the update available and the update verify - * packet. Thus the APID must be specified here. - * @param image The image to update on a NVM (A - 0, B - 1) - * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, - * application - 4 - * @param imageSize The size of the update image - * param numPackets The number of space packets required to transfer all data. - */ - UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, - uint32_t imageCrc, uint32_t numPackets) : - SupvTcSpacePacket(PAYLOAD_LENGTH, apid), image(image), partition(partition), imageSize( - imageSize), imageCrc(imageCrc), numPackets(numPackets) { - initPacket(); - makeCrc(); - } + private: + static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field -private: + uint8_t image = 0; + uint8_t partition = 0; + uint32_t imageSize = 0; + uint32_t imageCrc = 0; + uint32_t numPackets = 0; - static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field - - uint8_t image = 0; - uint8_t partition = 0; - uint32_t imageSize = 0; - uint32_t imageCrc = 0; - uint32_t numPackets = 0; - - void initPacket() { - size_t serializedSize = 0; - uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, - sizeof(image), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, - sizeof(partition), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, - sizeof(imageSize), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, - sizeof(imageCrc), SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&numPackets, &data_field_ptr, &serializedSize, - sizeof(numPackets), SerializeIF::Endianness::BIG); - } + void initPacket() { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, sizeof(image), + SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, + sizeof(partition), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageSize, &data_field_ptr, &serializedSize, + sizeof(imageSize), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&imageCrc, &data_field_ptr, &serializedSize, + sizeof(imageCrc), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&numPackets, &data_field_ptr, &serializedSize, + sizeof(numPackets), SerializeIF::Endianness::BIG); + } }; /** * @brief This class packages the space packet transporting a part of an MPSoC update. */ -class UpdatePacket: public SupvTcSpacePacket { -public: +class UpdatePacket : public SupvTcSpacePacket { + public: + /** + * @brief Constructor + * + * @param payloadLength Update data length (data field length without CRC) + */ + UpdatePacket(uint16_t payloadLength) : SupvTcSpacePacket(payloadLength, APID_UPDATE_IMAGE_DATA) {} - /** - * @brief Constructor - * - * @param payloadLength Update data length (data field length without CRC) - */ - UpdatePacket(uint16_t payloadLength) : - SupvTcSpacePacket(payloadLength, APID_UPDATE_IMAGE_DATA) { - } - - /** - * @brief Returns the pointer to the beginning of the data field. - */ - uint8_t* getDataFieldPointer() { - return this->localData.fields.buffer; - } + /** + * @brief Returns the pointer to the beginning of the data field. + */ + uint8_t* getDataFieldPointer() { return this->localData.fields.buffer; } }; /** * @brief This dataset stores the boot status report of the supervisor. */ -class BootStatusReport: public StaticLocalDataSet { -public: +class BootStatusReport : public StaticLocalDataSet { + public: + BootStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {} - BootStatusReport(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) { - } + BootStatusReport(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {} - BootStatusReport(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) { - } - - /** Information about boot status of MPSoC */ - lp_var_t bootSignal = lp_var_t(sid.objectId, PoolIds::BOOT_SIGNAL, this); - lp_var_t resetCounter = lp_var_t(sid.objectId, PoolIds::RESET_COUNTER, this); - /** Time the MPSoC needs for last boot */ - lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); - /** The currently set boot timeout */ - lp_var_t bootTimeoutMs = lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); - lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); - /** States of the boot partition pins */ - lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); - lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); - lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); + /** Information about boot status of MPSoC */ + lp_var_t bootSignal = lp_var_t(sid.objectId, PoolIds::BOOT_SIGNAL, this); + lp_var_t resetCounter = lp_var_t(sid.objectId, PoolIds::RESET_COUNTER, this); + /** Time the MPSoC needs for last boot */ + lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); + /** The currently set boot timeout */ + lp_var_t bootTimeoutMs = + lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); + lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); + /** States of the boot partition pins */ + lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); + lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); + lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); }; /** * @brief This dataset stores the housekeeping data of the supervisor. */ -class HkSet: public StaticLocalDataSet { -public: +class HkSet : public StaticLocalDataSet { + public: + HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {} - HkSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, HK_SET_ID) { - } + HkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {} - HkSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) { - } - - lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); - lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); - lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); - lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, - this); - lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); - lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); - lp_var_t socState = lp_var_t(sid.objectId, PoolIds::SOC_STATE, this); - lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); - lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); - lp_var_t missionIoState = lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, - this); - lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); + lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); + lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); + lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); + lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, this); + lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); + lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); + lp_var_t socState = lp_var_t(sid.objectId, PoolIds::SOC_STATE, this); + lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); + lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); + lp_var_t missionIoState = + lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, this); + lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); }; /** * @brief This dataset stores the last requested latchup status report. */ -class LatchupStatusReport: public StaticLocalDataSet { -public: +class LatchupStatusReport : public StaticLocalDataSet { + public: + LatchupStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LATCHUP_RPT_ID) {} - LatchupStatusReport(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, LATCHUP_RPT_ID) { - } + LatchupStatusReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) {} - LatchupStatusReport(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) { - } - - lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); - lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); - lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); - lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); - lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); - lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); - lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); - lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); - lp_var_t timeSec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); - lp_var_t timeMin = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); - lp_var_t timeHour = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); - lp_var_t timeDay = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); - lp_var_t timeMon = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); - lp_var_t timeYear = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); - lp_var_t timeMsec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); - lp_var_t isSet = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); + lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); + lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); + lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); + lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); + lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); + lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); + lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); + lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); + lp_var_t timeSec = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); + lp_var_t timeMin = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); + lp_var_t timeHour = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); + lp_var_t timeDay = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); + lp_var_t timeMon = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); + lp_var_t timeYear = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); + lp_var_t timeMsec = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); + lp_var_t isSet = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); }; -} +} // namespace PLOC_SPV #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp index 4e7c9458..9d8d7bbf 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.cpp @@ -1,78 +1,62 @@ #include "ArcsecDatalinkLayer.h" -ArcsecDatalinkLayer::ArcsecDatalinkLayer() { - slipInit(); -} +ArcsecDatalinkLayer::ArcsecDatalinkLayer() { slipInit(); } -ArcsecDatalinkLayer::~ArcsecDatalinkLayer() { -} +ArcsecDatalinkLayer::~ArcsecDatalinkLayer() {} void ArcsecDatalinkLayer::slipInit() { - slipInfo.buffer = rxBuffer; - slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; - slipInfo.length = 0; - slipInfo.unescape_next = 0; - slipInfo.prev_state = SLIP_COMPLETE; + slipInfo.buffer = rxBuffer; + slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE; + slipInfo.length = 0; + slipInfo.unescape_next = 0; + slipInfo.prev_state = SLIP_COMPLETE; } ReturnValue_t ArcsecDatalinkLayer::decodeFrame(const uint8_t* rawData, size_t rawDataSize, - 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); - *bytesLeft = rawDataSize - bytePos - 1; - switch (decResult) { - case ARC_DEC_INPROGRESS: { - if (bytePos == rawDataSize - 1) { - return DEC_IN_PROGRESS; - } - continue; - } - case ARC_DEC_ERROR_FRAME_SHORT: - return REPLY_TOO_SHORT; - case ARC_DEC_ERROR_CHECKSUM: - return CRC_FAILURE; - case ARC_DEC_ASYNC: - case ARC_DEC_SYNC: { - // Reset length of SLIP struct for next frame - slipInfo.length = 0; - return RETURN_OK; - } - default: - sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; - break; - return RETURN_FAILED; + 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); + *bytesLeft = rawDataSize - bytePos - 1; + switch (decResult) { + case ARC_DEC_INPROGRESS: { + if (bytePos == rawDataSize - 1) { + return DEC_IN_PROGRESS; } + continue; + } + case ARC_DEC_ERROR_FRAME_SHORT: + return REPLY_TOO_SHORT; + case ARC_DEC_ERROR_CHECKSUM: + return CRC_FAILURE; + case ARC_DEC_ASYNC: + case ARC_DEC_SYNC: { + // Reset length of SLIP struct for next frame + slipInfo.length = 0; + return RETURN_OK; + } + default: + sif::debug << "ArcsecDatalinkLayer::decodeFrame: Unknown result code" << std::endl; + break; + return RETURN_FAILED; } - return RETURN_FAILED; + } + 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); + 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); } diff --git a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h index a65881c7..6b4d3095 100644 --- a/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h +++ b/bsp_q7s/devices/startracker/ArcsecDatalinkLayer.h @@ -5,96 +5,94 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" extern "C" { - #include "common/misc.h" +#include "common/misc.h" } /** * @brief Helper class to handle the datalinklayer of replies from the star tracker of arcsec. */ -class ArcsecDatalinkLayer: public HasReturnvaluesIF { -public: +class ArcsecDatalinkLayer : public HasReturnvaluesIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + //! [EXPORT] : [COMMENT] More data required to complete frame + static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Data too short to represent a valid frame + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Detected CRC failure in received frame + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] More data required to complete frame - static const ReturnValue_t DEC_IN_PROGRESS = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Data too short to represent a valid frame - static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Detected CRC failure in received frame - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA2); + static const uint8_t STATUS_OK = 0; - static const uint8_t STATUS_OK = 0; + ArcsecDatalinkLayer(); + virtual ~ArcsecDatalinkLayer(); - ArcsecDatalinkLayer(); - virtual ~ArcsecDatalinkLayer(); + /** + * @brief Applies decoding to data referenced by rawData pointer + * + * @param rawData Pointer to raw data received from star tracker + * @param rawDataSize Size of raw data stream + * @param remainingBytes Number of bytes left + */ + ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); - /** - * @brief Applies decoding to data referenced by rawData pointer - * - * @param rawData Pointer to raw data received from star tracker - * @param rawDataSize Size of raw data stream - * @param remainingBytes Number of bytes left - */ - ReturnValue_t decodeFrame(const uint8_t* rawData, size_t rawDataSize, size_t* bytesLeft); + /** + * @brief SLIP encodes data pointed to by data pointer. + * + * @param data Pointer to data to encode + * @param length Length of buffer to encode + */ + void encodeFrame(const uint8_t* data, uint32_t length); - /** - * @brief SLIP encodes data pointed to by data pointer. - * - * @param data Pointer to data to encode - * @param length Length of buffer to encode - */ - void encodeFrame(const uint8_t* data, uint32_t length); + /** + * @brief Returns the frame type field of a decoded frame. + */ + uint8_t getReplyFrameType(); - /** - * @brief Returns the frame type field of a decoded frame. - */ - uint8_t getReplyFrameType(); + /** + * @brief Returns pointer to reply packet (first entry normally action ID, telemetry ID etc.) + */ + const uint8_t* getReply(); - /** - * @brief Returns pointer to reply packet (first entry normally action ID, telemetry ID etc.) - */ - const uint8_t* getReply(); + /** + * @brief Returns size of encoded frame + */ + uint32_t getEncodedLength(); - /** - * @brief Returns size of encoded frame - */ - uint32_t getEncodedLength(); + /** + * @brief Returns pointer to encoded frame + */ + uint8_t* getEncodedFrame(); - /** - * @brief Returns pointer to encoded frame - */ - uint8_t* getEncodedFrame(); + /** + * @brief Returns status of reply + */ + uint8_t getStatusField(); - /** - * @brief Returns status of reply - */ - uint8_t getStatusField(); + /** + * @brief Returns ID of reply + */ + uint8_t getId(); - /** - * @brief Returns ID of reply - */ - uint8_t getId(); + private: + static const uint8_t ID_OFFSET = 1; + static const uint8_t STATUS_OFFSET = 2; -private: + // Used by arcsec slip decoding function process received data + uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; + // Decoded frame will be copied to this buffer + uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; + // Buffer where encoded frames will be stored. First byte of encoded frame represents type of + // reply + uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; + // Size of decoded frame + uint32_t decFrameSize = 0; + // Size of encoded frame + uint32_t encFrameSize = 0; - static const uint8_t ID_OFFSET = 1; - static const uint8_t STATUS_OFFSET = 2; + slip_decode_state slipInfo; - // Used by arcsec slip decoding function process received data - uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE]; - // Decoded frame will be copied to this buffer - uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE]; - // Buffer where encoded frames will be stored. First byte of encoded frame represents type of - // reply - uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2]; - // Size of decoded frame - uint32_t decFrameSize = 0; - // Size of encoded frame - uint32_t encFrameSize = 0; - - slip_decode_state slipInfo; - - void slipInit(); + void slipInit(); }; #endif /* BSP_Q7S_DEVICES_ARCSECDATALINKLAYER_H_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h index 2c598b43..67a80b88 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonKeys.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonKeys.h @@ -5,122 +5,122 @@ * @brief Keys used in JSON file of ARCSEC. */ namespace arcseckeys { - static const char PROPERTIES[] = "properties"; - static const char NAME[] = "name"; - static const char VALUE[] = "value"; +static const char PROPERTIES[] = "properties"; +static const char NAME[] = "name"; +static const char VALUE[] = "value"; - static const char LIMITS[] = "limits"; - static const char ACTION[] = "action"; - static const char FPGA18CURRENT[] = "FPGA18Current"; - static const char FPGA25CURRENT[] = "FPGA25Current"; - static const char FPGA10CURRENT[] = "FPGA10Current"; - static const char MCUCURRENT[] = "MCUCurrent"; - static const char CMOS21CURRENT[] = "CMOS21Current"; - static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; - static const char CMOS33CURRENT[] = "CMOS33Current"; - static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; - static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; - static const char MCU_TEMPERATURE[] = "MCUTemperature"; +static const char LIMITS[] = "limits"; +static const char ACTION[] = "action"; +static const char FPGA18CURRENT[] = "FPGA18Current"; +static const char FPGA25CURRENT[] = "FPGA25Current"; +static const char FPGA10CURRENT[] = "FPGA10Current"; +static const char MCUCURRENT[] = "MCUCurrent"; +static const char CMOS21CURRENT[] = "CMOS21Current"; +static const char CMOSPIXCURRENT[] = "CMOSPixCurrent"; +static const char CMOS33CURRENT[] = "CMOS33Current"; +static const char CMOSVRESCURRENT[] = "CMOSVResCurrent"; +static const char CMOS_TEMPERATURE[] = "CMOSTemperature"; +static const char MCU_TEMPERATURE[] = "MCUTemperature"; - static const char MOUNTING[] = "mounting"; - static const char qw[] = "qw"; - static const char qx[] = "qx"; - static const char qy[] = "qy"; - static const char qz[] = "qz"; +static const char MOUNTING[] = "mounting"; +static const char qw[] = "qw"; +static const char qx[] = "qx"; +static const char qy[] = "qy"; +static const char qz[] = "qz"; - static const char CAMERA[] = "camera"; - static const char MODE[] = "mode"; - static const char FOCALLENGTH[] = "focallength"; - static const char EXPOSURE[] = "exposure"; - static const char INTERVAL[] = "interval"; - static const char OFFSET[] = "offset"; - static const char PGAGAIN[] = "PGAGain"; - static const char ADCGAIN[] = "ADCGain"; - static const char REG_1[] = "reg1"; - static const char VAL_1[] = "val1"; - static const char REG_2[] = "reg2"; - static const char VAL_2[] = "val2"; - static const char REG_3[] = "reg3"; - static const char VAL_3[] = "val3"; - static const char REG_4[] = "reg4"; - static const char VAL_4[] = "val4"; - static const char REG_5[] = "reg5"; - static const char VAL_5[] = "val5"; - static const char REG_6[] = "reg6"; - static const char VAL_6[] = "val6"; - static const char REG_7[] = "reg7"; - static const char VAL_7[] = "val7"; - static const char REG_8[] = "reg8"; - static const char VAL_8[] = "val8"; - static const char FREQ_1[] = "freq1"; - static const char FREQ_2[] = "freq2"; +static const char CAMERA[] = "camera"; +static const char MODE[] = "mode"; +static const char FOCALLENGTH[] = "focallength"; +static const char EXPOSURE[] = "exposure"; +static const char INTERVAL[] = "interval"; +static const char OFFSET[] = "offset"; +static const char PGAGAIN[] = "PGAGain"; +static const char ADCGAIN[] = "ADCGain"; +static const char REG_1[] = "reg1"; +static const char VAL_1[] = "val1"; +static const char REG_2[] = "reg2"; +static const char VAL_2[] = "val2"; +static const char REG_3[] = "reg3"; +static const char VAL_3[] = "val3"; +static const char REG_4[] = "reg4"; +static const char VAL_4[] = "val4"; +static const char REG_5[] = "reg5"; +static const char VAL_5[] = "val5"; +static const char REG_6[] = "reg6"; +static const char VAL_6[] = "val6"; +static const char REG_7[] = "reg7"; +static const char VAL_7[] = "val7"; +static const char REG_8[] = "reg8"; +static const char VAL_8[] = "val8"; +static const char FREQ_1[] = "freq1"; +static const char FREQ_2[] = "freq2"; - static const char BLOB[] = "blob"; - static const char MIN_VALUE[] = "minValue"; - static const char MIN_DISTANCE[] = "minDistance"; - static const char NEIGHBOUR_DISTANCE[] = "neighbourDistance"; - static const char NEIGHBOUR_BRIGHT_PIXELS[] = "neighbourBrightPixels"; - static const char MIN_TOTAL_VALUE[] = "minTotalValue"; - static const char MAX_TOTAL_VALUE[] = "maxTotalValue"; - static const char MIN_BRIGHT_NEIGHBOURS[] = "minBrightNeighbours"; - static const char MAX_BRIGHT_NEIGHBOURS[] = "maxBrightNeighbours"; - static const char MAX_PIXEL_TO_CONSIDER[] = "maxPixelsToConsider"; - static const char SIGNAL_THRESHOLD[] = "signalThreshold"; - static const char DARK_THRESHOLD[] = "darkThreshold"; - static const char ENABLE_HISTOGRAM[] = "enableHistogram"; - static const char ENABLE_CONTRAST[] = "enableContrast"; - static const char BIN_MODE[] = "binMode"; +static const char BLOB[] = "blob"; +static const char MIN_VALUE[] = "minValue"; +static const char MIN_DISTANCE[] = "minDistance"; +static const char NEIGHBOUR_DISTANCE[] = "neighbourDistance"; +static const char NEIGHBOUR_BRIGHT_PIXELS[] = "neighbourBrightPixels"; +static const char MIN_TOTAL_VALUE[] = "minTotalValue"; +static const char MAX_TOTAL_VALUE[] = "maxTotalValue"; +static const char MIN_BRIGHT_NEIGHBOURS[] = "minBrightNeighbours"; +static const char MAX_BRIGHT_NEIGHBOURS[] = "maxBrightNeighbours"; +static const char MAX_PIXEL_TO_CONSIDER[] = "maxPixelsToConsider"; +static const char SIGNAL_THRESHOLD[] = "signalThreshold"; +static const char DARK_THRESHOLD[] = "darkThreshold"; +static const char ENABLE_HISTOGRAM[] = "enableHistogram"; +static const char ENABLE_CONTRAST[] = "enableContrast"; +static const char BIN_MODE[] = "binMode"; - static const char CENTROIDING[] = "centroiding"; - static const char ENABLE_FILTER[] = "enableFilter"; - static const char MAX_QUALITY[] = "maxquality"; - static const char MIN_QUALITY[] = "minquality"; - static const char MAX_INTENSITY[] = "maxintensity"; - static const char MIN_INTENSITY[] = "minintensity"; - static const char MAX_MAGNITUDE[] = "maxmagnitude"; - static const char GAUSSIAN_CMAX[] = "gaussianCmax"; - static const char GAUSSIAN_CMIN[] = "gaussianCmin"; - static const char TRANSMATRIX_00[] = "transmatrix00"; - static const char TRANSMATRIX_01[] = "transmatrix01"; - static const char TRANSMATRIX_10[] = "transmatrix10"; - static const char TRANSMATRIX_11[] = "transmatrix11"; +static const char CENTROIDING[] = "centroiding"; +static const char ENABLE_FILTER[] = "enableFilter"; +static const char MAX_QUALITY[] = "maxquality"; +static const char MIN_QUALITY[] = "minquality"; +static const char MAX_INTENSITY[] = "maxintensity"; +static const char MIN_INTENSITY[] = "minintensity"; +static const char MAX_MAGNITUDE[] = "maxmagnitude"; +static const char GAUSSIAN_CMAX[] = "gaussianCmax"; +static const char GAUSSIAN_CMIN[] = "gaussianCmin"; +static const char TRANSMATRIX_00[] = "transmatrix00"; +static const char TRANSMATRIX_01[] = "transmatrix01"; +static const char TRANSMATRIX_10[] = "transmatrix10"; +static const char TRANSMATRIX_11[] = "transmatrix11"; - static const char LISA[] = "lisa"; - static const char PREFILTER_DIST_THRESHOLD[] = "prefilterDistThreshold"; - static const char PREFILTER_ANGLE_THRESHOLD[] = "prefilterAngleThreshold"; - static const char FOV_WIDTH[] = "fov_width"; - static const char FOV_HEIGHT[] = "fov_height"; - static const char FLOAT_STAR_LIMIT[] = "float_star_limit"; - static const char CLOSE_STAR_LIMIT[] = "close_star_limit"; - static const char RATING_WEIGHT_CLOSE_STAR_COUNT[] = "rating_weight_close_star_count"; - static const char RATING_WEIGHT_FRACTION_CLOSE[] = "rating_weight_fraction_close"; - static const char RATING_WEIGHT_MEAN_SUM[] = "rating_weight_mean_sum"; - static const char RATING_WEIGHT_DB_STAR_COUNT[] = "rating_weight_db_star_count"; - static const char MAX_COMBINATIONS[] = "max_combinations"; - static const char NR_STARS_STOP[] = "nr_stars_stop"; - static const char FRACTION_CLOSE_STOP[] = "fraction_close_stop"; +static const char LISA[] = "lisa"; +static const char PREFILTER_DIST_THRESHOLD[] = "prefilterDistThreshold"; +static const char PREFILTER_ANGLE_THRESHOLD[] = "prefilterAngleThreshold"; +static const char FOV_WIDTH[] = "fov_width"; +static const char FOV_HEIGHT[] = "fov_height"; +static const char FLOAT_STAR_LIMIT[] = "float_star_limit"; +static const char CLOSE_STAR_LIMIT[] = "close_star_limit"; +static const char RATING_WEIGHT_CLOSE_STAR_COUNT[] = "rating_weight_close_star_count"; +static const char RATING_WEIGHT_FRACTION_CLOSE[] = "rating_weight_fraction_close"; +static const char RATING_WEIGHT_MEAN_SUM[] = "rating_weight_mean_sum"; +static const char RATING_WEIGHT_DB_STAR_COUNT[] = "rating_weight_db_star_count"; +static const char MAX_COMBINATIONS[] = "max_combinations"; +static const char NR_STARS_STOP[] = "nr_stars_stop"; +static const char FRACTION_CLOSE_STOP[] = "fraction_close_stop"; - static const char MATCHING[] = "matching"; - static const char SQUARED_DISTANCE_LIMIT[] = "squaredDistanceLimit"; - static const char SQUARED_SHIFT_LIMIT[] = "squaredShiftLimit"; +static const char MATCHING[] = "matching"; +static const char SQUARED_DISTANCE_LIMIT[] = "squaredDistanceLimit"; +static const char SQUARED_SHIFT_LIMIT[] = "squaredShiftLimit"; - static const char VALIDATION[] = "validation"; - static const char STABLE_COUNT[] = "stable_count"; - static const char MAX_DIFFERENCE[] = "max_difference"; - static const char MIN_TRACKER_CONFIDENCE[] = "min_trackerConfidence"; - static const char MIN_MATCHED_STARS[] = "min_matchedStars"; +static const char VALIDATION[] = "validation"; +static const char STABLE_COUNT[] = "stable_count"; +static const char MAX_DIFFERENCE[] = "max_difference"; +static const char MIN_TRACKER_CONFIDENCE[] = "min_trackerConfidence"; +static const char MIN_MATCHED_STARS[] = "min_matchedStars"; - static const char TRACKING[] = "tracking"; - static const char THIN_LIMIT[] = "thinLimit"; - static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; - static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; - static const char TRACKER_CHOICE[] = "trackerChoice"; +static const char TRACKING[] = "tracking"; +static const char THIN_LIMIT[] = "thinLimit"; +static const char OUTLIER_THRESHOLD[] = "outlierThreshold"; +static const char OUTLIER_THRESHOLD_QUEST[] = "outlierThresholdQUEST"; +static const char TRACKER_CHOICE[] = "trackerChoice"; - static const char ALGO[] = "algo"; - static const char L2T_MIN_CONFIDENCE[] = "l2t_minConfidence"; - static const char L2T_MIN_MATCHED[] = "l2t_minConfidence"; - static const char T2L_MIN_CONFIDENCE[] = "t2l_minConfidence"; - static const char T2L_MIN_MATCHED[] = "t2l_minMatched"; -} +static const char ALGO[] = "algo"; +static const char L2T_MIN_CONFIDENCE[] = "l2t_minConfidence"; +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_ */ diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp index 339c3fe7..3ecd1d91 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.cpp @@ -1,94 +1,95 @@ #include "ArcsecJsonParamBase.h" + #include "ArcsecJsonKeys.h" ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {} ReturnValue_t ArcsecJsonParamBase::create(std::string fullname, uint8_t* buffer) { - ReturnValue_t result = RETURN_OK; - result = init(fullname); - if (result != RETURN_OK) { - return result; - } - result = createCommand(buffer); + ReturnValue_t result = RETURN_OK; + result = init(fullname); + if (result != RETURN_OK) { return result; + } + result = createCommand(buffer); + return result; } ReturnValue_t ArcsecJsonParamBase::getParam(const std::string name, std::string& value) { - for (json::iterator it = set.begin(); it != set.end(); ++it) { - if ((*it)[arcseckeys::NAME] == name) { - value = (*it)[arcseckeys::VALUE]; - convertEmpty(value); - return RETURN_OK; - } + for (json::iterator it = set.begin(); it != set.end(); ++it) { + if ((*it)[arcseckeys::NAME] == name) { + value = (*it)[arcseckeys::VALUE]; + convertEmpty(value); + return RETURN_OK; } - return PARAM_NOT_EXISTS; + } + return PARAM_NOT_EXISTS; } void ArcsecJsonParamBase::convertEmpty(std::string& value) { - if (value == "") { - value = "0"; - } + if (value == "") { + value = "0"; + } } void ArcsecJsonParamBase::addfloat(const std::string value, uint8_t* buffer) { - float param = std::stof(value); - std::memcpy(buffer, ¶m, sizeof(param)); + float param = std::stof(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint8(const std::string value, uint8_t* buffer) { - uint8_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint8_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::addint16(const std::string value, uint8_t* buffer) { - int16_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + int16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint16(const std::string value, uint8_t* buffer) { - uint16_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint16_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::adduint32(const std::string value, uint8_t* buffer) { - uint32_t param = std::stoi(value); - std::memcpy(buffer, ¶m, sizeof(param)); + uint32_t param = std::stoi(value); + std::memcpy(buffer, ¶m, sizeof(param)); } void ArcsecJsonParamBase::addSetParamHeader(uint8_t* buffer, uint8_t setId) { - *buffer = static_cast(TMTC_SETPARAMREQ); - *(buffer + 1) = setId; + *buffer = static_cast(TMTC_SETPARAMREQ); + *(buffer + 1) = setId; } ReturnValue_t ArcsecJsonParamBase::init(const std::string filename) { - ReturnValue_t result = RETURN_OK; - if (not std::filesystem::exists(filename)) { - sif::warning << "ArcsecJsonParamBase::init: JSON file " << filename << " does not exist" - << std::endl; - return JSON_FILE_NOT_EXISTS; - } - createJsonObject(filename); - result = initSet(); - if (result != RETURN_OK) { - return result; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + if (not std::filesystem::exists(filename)) { + sif::warning << "ArcsecJsonParamBase::init: JSON file " << filename << " does not exist" + << std::endl; + return JSON_FILE_NOT_EXISTS; + } + createJsonObject(filename); + result = initSet(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } void ArcsecJsonParamBase::createJsonObject(const std::string fullname) { - json j; - std::ifstream file(fullname); - file >> j; - file.close(); - properties = j[arcseckeys::PROPERTIES]; + json j; + std::ifstream file(fullname); + file >> j; + file.close(); + properties = j[arcseckeys::PROPERTIES]; } ReturnValue_t ArcsecJsonParamBase::initSet() { - for (json::iterator it = properties.begin(); it != properties.end(); ++it) { - if ((*it)["name"] == setName) { - set = (*it)["fields"]; - return RETURN_OK; - } + for (json::iterator it = properties.begin(); it != properties.end(); ++it) { + if ((*it)["name"] == setName) { + set = (*it)["fields"]; + return RETURN_OK; } - return SET_NOT_EXISTS; + } + return SET_NOT_EXISTS; } diff --git a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h index 320eff53..a3e7528f 100644 --- a/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h +++ b/bsp_q7s/devices/startracker/ArcsecJsonParamBase.h @@ -1,16 +1,16 @@ #ifndef BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ #define BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ -#include #include +#include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "StarTrackerDefinitions.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" extern "C" { - #include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" - #include "thirdparty/arcsec_star_tracker/common/genericstructs.h" +#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" +#include "thirdparty/arcsec_star_tracker/common/genericstructs.h" } using json = nlohmann::json; @@ -23,127 +23,124 @@ using json = nlohmann::json; * @author J. Meier */ class ArcsecJsonParamBase : public HasReturnvaluesIF { -public: + 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); + //! [EXPORT] : [COMMENT] Requested set does not exist in json file + static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); + //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file + static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); - 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); - //! [EXPORT] : [COMMENT] Requested set does not exist in json file - static const ReturnValue_t SET_NOT_EXISTS = MAKE_RETURN_CODE(2); - //! [EXPORT] : [COMMENT] Requested parameter does not exist in json file - static const ReturnValue_t PARAM_NOT_EXISTS = MAKE_RETURN_CODE(3); + /** + * @brief Constructor + * + * @param fullname Name with absolute path of json file containing the parameters to set. + */ + ArcsecJsonParamBase(std::string setName); - /** - * @brief Constructor - * - * @param fullname Name with absolute path of json file containing the parameters to set. - */ - ArcsecJsonParamBase(std::string setName); + /** + * @brief Fills a buffer with a parameter set + * + * @param fullname The name including the absolute path of the json file containing the + * parameter set. + * @param buffer Pointer to the buffer the command will be written to + */ + ReturnValue_t create(std::string fullname, uint8_t* buffer); - /** - * @brief Fills a buffer with a parameter set - * - * @param fullname The name including the absolute path of the json file containing the - * parameter set. - * @param buffer Pointer to the buffer the command will be written to - */ - ReturnValue_t create(std::string fullname, uint8_t* buffer); + /** + * @brief Returns the size of the parameter command. + */ + virtual size_t getSize() = 0; - /** - * @brief Returns the size of the parameter command. - */ - virtual size_t getSize() = 0; + protected: + /** + * @brief Reads the value of a parameter from a json set + * + * @param name The name of the parameter + * @param value The string representation of the read value + * + * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS + */ + ReturnValue_t getParam(const std::string name, std::string& value); -protected: + /** + * @brief Converts empty string which is equal to define a value as zero. + */ + void convertEmpty(std::string& value); - /** - * @brief Reads the value of a parameter from a json set - * - * @param name The name of the parameter - * @param value The string representation of the read value - * - * @return RETURN_OK if successful, otherwise PARAM_NOT_EXISTS - */ - ReturnValue_t getParam(const std::string name, std::string& value); + /** + * @brief This function adds a float represented as string to a buffer + * + * @param value The float in string representation to add + * @param buffer Pointer to the buffer the float will be written to + */ + void addfloat(const std::string value, uint8_t* buffer); - /** - * @brief Converts empty string which is equal to define a value as zero. - */ - void convertEmpty(std::string& value); + /** + * @brief This function adds a uint8_t represented as string to a buffer + * + * @param value The uint8_t in string representation to add + * @param buffer Pointer to the buffer the uint8_t will be written to + */ + void adduint8(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a float represented as string to a buffer - * - * @param value The float in string representation to add - * @param buffer Pointer to the buffer the float will be written to - */ - void addfloat(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a int16_t represented as string to a buffer + * + * @param value The int16_t in string representation to add + * @param buffer Pointer to the buffer the int16_t will be written to + */ + void addint16(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a uint8_t represented as string to a buffer - * - * @param value The uint8_t in string representation to add - * @param buffer Pointer to the buffer the uint8_t will be written to - */ - void adduint8(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a uint16_t represented as string to a buffer + * + * @param value The uint16_t in string representation to add + * @param buffer Pointer to the buffer the uint16_t will be written to + */ + void adduint16(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a int16_t represented as string to a buffer - * - * @param value The int16_t in string representation to add - * @param buffer Pointer to the buffer the int16_t will be written to - */ - void addint16(const std::string value, uint8_t* buffer); + /** + * @brief This function adds a uint32_t represented as string to a buffer + * + * @param value The uint32_t in string representation to add + * @param buffer Pointer to the buffer the uint32_t will be written to + */ + void adduint32(const std::string value, uint8_t* buffer); - /** - * @brief This function adds a uint16_t represented as string to a buffer - * - * @param value The uint16_t in string representation to add - * @param buffer Pointer to the buffer the uint16_t will be written to - */ - void adduint16(const std::string value, uint8_t* buffer); + void addSetParamHeader(uint8_t* buffer, uint8_t setId); - /** - * @brief This function adds a uint32_t represented as string to a buffer - * - * @param value The uint32_t in string representation to add - * @param buffer Pointer to the buffer the uint32_t will be written to - */ - void adduint32(const std::string value, uint8_t* buffer); + private: + json properties; + json set; + std::string setName; - void addSetParamHeader(uint8_t* buffer, uint8_t setId); + /** + * @brief This function must be implemented by the derived class to define creation of a + * parameter command. + */ + virtual ReturnValue_t createCommand(uint8_t* buffer) = 0; -private: + /** + * @brief Initializes the properties json object and the set json object + * + * @param fullname Name including absolute path to json file + * @param setName The name of the set to work on + * + * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise + * RETURN_OK + */ + ReturnValue_t init(const std::string filename); - json properties; - json set; - std::string setName; + void createJsonObject(const std::string fullname); - /** - * @brief This function must be implemented by the derived class to define creation of a - * parameter command. - */ - virtual ReturnValue_t createCommand(uint8_t* buffer) = 0; - - /** - * @brief Initializes the properties json object and the set json object - * - * @param fullname Name including absolute path to json file - * @param setName The name of the set to work on - * - * @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise - * RETURN_OK - */ - ReturnValue_t init(const std::string filename); - - void createJsonObject(const std::string fullname); - - /** - * @brief Extracts the json set object form the json file - * - * @param setName The name of the set to create the json object from - */ - ReturnValue_t initSet(); + /** + * @brief Extracts the json set object form the json file + * + * @param setName The name of the set to create the json object from + */ + ReturnValue_t initSet(); }; #endif /* BSP_Q7S_DEVICES_STARTRACKER_ARCSECJSONPARAMBASE_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h index 1f20c606..1e0564d9 100644 --- a/bsp_q7s/devices/startracker/StarTrackerDefinitions.h +++ b/bsp_q7s/devices/startracker/StarTrackerDefinitions.h @@ -1,12 +1,13 @@ #ifndef MISSION_STARTRACKER_DEFINITIONS_H_ #define MISSION_STARTRACKER_DEFINITIONS_H_ -#include +#include #include +#include #include #include + #include "objects/systemObjectList.h" -#include namespace StarTracker { @@ -15,229 +16,229 @@ static const uint8_t ADDRESS = 33; static const uint8_t STATUS_OK = 0; -enum PoolIds: lp_id_t { - TICKS_TIME_SET, - TIME_TIME_SET, - RUN_TIME, - UNIX_TIME, - TICKS_VERSION_SET, - TIME_VERSION_SET, - PROGRAM, - MAJOR, - MINOR, - TICKS_INTERFACE_SET, - TIME_INTERFACE_SET, - FRAME_COUNT, - CHECKSUM_ERROR_COUNT, - SET_PARAM_COUNT, - SET_PARAM_REPLY_COUNT, - PARAM_REQUEST_COUNT, - PARAM_REPLY_COUNT, - REQ_TM_COUNT, - TM_REPLY_COUNT, - ACTION_REQ_COUNT, - ACTION_REPLY_COUNT, - TICKS_POWER_SET, - TIME_POWER_SET, - MCU_CURRENT, - MCU_VOLTAGE, - FPGA_CORE_CURRENT, - FPGA_CORE_VOLTAGE, - FPGA_18_CURRENT, - FPGA_18_VOLTAGE, - FPGA_25_CURRENT, - FPGA_25_VOLTAGE, - CMV_21_CURRENT, - CMV_21_VOLTAGE, - CMV_PIX_CURRENT, - CMV_PIX_VOLTAGE, - CMV_33_CURRENT, - CMV_33_VOLTAGE, - CMV_RES_CURRENT, - CMV_RES_VOLTAGE, - TICKS_TEMPERATURE_SET, - TIME_TEMPERATURE_SET, - MCU_TEMPERATURE, - CMOS_TEMPERATURE, - TICKS_SOLUTION_SET, - TIME_SOLUTION_SET, - CALI_QW, - CALI_QX, - CALI_QY, - CALI_QZ, - TRACK_CONFIDENCE, - TRACK_QW, - TRACK_QX, - TRACK_QY, - TRACK_QZ, - TRACK_REMOVED, - STARS_CENTROIDED, - STARS_MATCHED_DATABASE, - LISA_QW, - LISA_QX, - LISA_QY, - LISA_QZ, - LISA_PERC_CLOSE, - LISA_NR_CLOSE, - TRUST_WORTHY, - STABLE_COUNT, - SOLUTION_STRATEGY, - TICKS_HISTOGRAM_SET, - TIME_HISTOGRAM_SET, - HISTOGRAM_BINA0, - HISTOGRAM_BINA1, - HISTOGRAM_BINA2, - HISTOGRAM_BINA3, - HISTOGRAM_BINA4, - HISTOGRAM_BINA5, - HISTOGRAM_BINA6, - HISTOGRAM_BINA7, - HISTOGRAM_BINA8, - HISTOGRAM_BINB0, - HISTOGRAM_BINB1, - HISTOGRAM_BINB2, - HISTOGRAM_BINB3, - HISTOGRAM_BINB4, - HISTOGRAM_BINB5, - HISTOGRAM_BINB6, - HISTOGRAM_BINB7, - HISTOGRAM_BINB8, - HISTOGRAM_BINC0, - HISTOGRAM_BINC1, - HISTOGRAM_BINC2, - HISTOGRAM_BINC3, - HISTOGRAM_BINC4, - HISTOGRAM_BINC5, - HISTOGRAM_BINC6, - HISTOGRAM_BINC7, - HISTOGRAM_BINC8, - HISTOGRAM_BIND0, - HISTOGRAM_BIND1, - HISTOGRAM_BIND2, - HISTOGRAM_BIND3, - HISTOGRAM_BIND4, - HISTOGRAM_BIND5, - HISTOGRAM_BIND6, - HISTOGRAM_BIND7, - HISTOGRAM_BIND8, - TICKS_CONTRAST_SET, - TIME_CONTRAST_SET, - CONTRAST_BINA0, - CONTRAST_BINA1, - CONTRAST_BINA2, - CONTRAST_BINA3, - CONTRAST_BINA4, - CONTRAST_BINA5, - CONTRAST_BINA6, - CONTRAST_BINA7, - CONTRAST_BINA8, - CONTRAST_BINB0, - CONTRAST_BINB1, - CONTRAST_BINB2, - CONTRAST_BINB3, - CONTRAST_BINB4, - CONTRAST_BINB5, - CONTRAST_BINB6, - CONTRAST_BINB7, - CONTRAST_BINB8, - CONTRAST_BINC0, - CONTRAST_BINC1, - CONTRAST_BINC2, - CONTRAST_BINC3, - CONTRAST_BINC4, - CONTRAST_BINC5, - CONTRAST_BINC6, - CONTRAST_BINC7, - CONTRAST_BINC8, - CONTRAST_BIND0, - CONTRAST_BIND1, - CONTRAST_BIND2, - CONTRAST_BIND3, - CONTRAST_BIND4, - CONTRAST_BIND5, - CONTRAST_BIND6, - CONTRAST_BIND7, - CONTRAST_BIND8, - CHKSUM, - DWL_ID, - DWL_PIXX, - DWL_PIXY, - DWL_X_UNCORRECTED, - DWL_Y_UNCORRECTED, - DWL_X_CORRECTED, - DWL_Y_CORRECTED, - DWL_MAGNITUDE, - DWL_CXA, - DWL_CYA, - DWL_QUALITY, - MATCHEDSTR_ID, - MATCHEDSTR_CAMFPX, - MATCHEDSTR_CAMFPY, - MATCHEDSTR_CAMCARTX, - MATCHEDSTR_CAMCARTY, - MATCHEDSTR_CAMCARTZ, - MATCHEDSTR_CAMMAGNITUDE, - MATCHEDSTR_DBFPX, - MATCHEDSTR_DBFPY, - MATCHEDSTR_DBCARTX, - MATCHEDSTR_DBCARTY, - MATCHEDSTR_DBCARTZ, - MATCHEDSTR_DBMAGNITUDE, - MATCHEDSTR_CATALOGID, - DBIMAGE_ID, - DBIMAGE_PIXX, - DBIMAGE_PIXY, - DBIMAGE_X, - DBIMAGE_Y, - DBIMAGE_MAGNITUDE, - BLOBPIX_ID, - BLOBPIX_X, - BLOBPIX_Y, - BLOBPIX_TOT_VAL, - BLOBPIX_IN_USE, - BLOBPIX_BRIGHT_NEIGHBOURS, - BLOBPIX_REGION, - CAMERA_MODE, - FOCALLENGTH, - EXPOSURE, - INTERVAL, - CAMERA_OFFSET, - PGAGAIN, - ADCGAIN, - CAM_REG1, - CAM_VAL1, - CAM_REG2, - CAM_VAL2, - CAM_REG3, - CAM_VAL3, - CAM_REG4, - CAM_VAL4, - LIMITS_ACTION, - LIMITS_FPGA18CURRENT, - LIMITS_FPGA25CURRENT, - LIMITS_FPGA10CURRENT, - LIMITS_MCUCURRENT, - LIMITS_CMOS21CURRENT, - LIMITS_CMOSPIXCURRENT, - LIMITS_CMOS33CURRENT, - LIMITS_CMOSVRESCURRENT, - LIMITS_CMOSTEMPERATURE, - LIMITS_MCUTEMPERATURE, - BLOB_MODE, - BLOB_MIN_VALUE, - BLOB_MIN_DISTANCE, - BLOB_NEIGHBOUR_DISTANCE, - BLOB_NEIGHBOUR_BRIGHTPIXELS, - BLOB_MIN_TOTAL_VALUE, - BLOB_MAX_TOTAL_VALUE, - BLOB_MIN_BRIGHT_NEIGHBOURS, - BLOB_MAX_BRIGHT_NEIGHBOURS, - BLOB_MAX_PIXELSTOCONSIDER, - BLOB_SIGNAL_THRESHOLD, - BLOB_DARK_THRESHOLD, - BLOB_ENABLE_HISTOGRAM, - BLOB_ENABLE_CONTRAST, - BLOB_BIN_MODE +enum PoolIds : lp_id_t { + TICKS_TIME_SET, + TIME_TIME_SET, + RUN_TIME, + UNIX_TIME, + TICKS_VERSION_SET, + TIME_VERSION_SET, + PROGRAM, + MAJOR, + MINOR, + TICKS_INTERFACE_SET, + TIME_INTERFACE_SET, + FRAME_COUNT, + CHECKSUM_ERROR_COUNT, + SET_PARAM_COUNT, + SET_PARAM_REPLY_COUNT, + PARAM_REQUEST_COUNT, + PARAM_REPLY_COUNT, + REQ_TM_COUNT, + TM_REPLY_COUNT, + ACTION_REQ_COUNT, + ACTION_REPLY_COUNT, + TICKS_POWER_SET, + TIME_POWER_SET, + MCU_CURRENT, + MCU_VOLTAGE, + FPGA_CORE_CURRENT, + FPGA_CORE_VOLTAGE, + FPGA_18_CURRENT, + FPGA_18_VOLTAGE, + FPGA_25_CURRENT, + FPGA_25_VOLTAGE, + CMV_21_CURRENT, + CMV_21_VOLTAGE, + CMV_PIX_CURRENT, + CMV_PIX_VOLTAGE, + CMV_33_CURRENT, + CMV_33_VOLTAGE, + CMV_RES_CURRENT, + CMV_RES_VOLTAGE, + TICKS_TEMPERATURE_SET, + TIME_TEMPERATURE_SET, + MCU_TEMPERATURE, + CMOS_TEMPERATURE, + TICKS_SOLUTION_SET, + TIME_SOLUTION_SET, + CALI_QW, + CALI_QX, + CALI_QY, + CALI_QZ, + TRACK_CONFIDENCE, + TRACK_QW, + TRACK_QX, + TRACK_QY, + TRACK_QZ, + TRACK_REMOVED, + STARS_CENTROIDED, + STARS_MATCHED_DATABASE, + LISA_QW, + LISA_QX, + LISA_QY, + LISA_QZ, + LISA_PERC_CLOSE, + LISA_NR_CLOSE, + TRUST_WORTHY, + STABLE_COUNT, + SOLUTION_STRATEGY, + TICKS_HISTOGRAM_SET, + TIME_HISTOGRAM_SET, + HISTOGRAM_BINA0, + HISTOGRAM_BINA1, + HISTOGRAM_BINA2, + HISTOGRAM_BINA3, + HISTOGRAM_BINA4, + HISTOGRAM_BINA5, + HISTOGRAM_BINA6, + HISTOGRAM_BINA7, + HISTOGRAM_BINA8, + HISTOGRAM_BINB0, + HISTOGRAM_BINB1, + HISTOGRAM_BINB2, + HISTOGRAM_BINB3, + HISTOGRAM_BINB4, + HISTOGRAM_BINB5, + HISTOGRAM_BINB6, + HISTOGRAM_BINB7, + HISTOGRAM_BINB8, + HISTOGRAM_BINC0, + HISTOGRAM_BINC1, + HISTOGRAM_BINC2, + HISTOGRAM_BINC3, + HISTOGRAM_BINC4, + HISTOGRAM_BINC5, + HISTOGRAM_BINC6, + HISTOGRAM_BINC7, + HISTOGRAM_BINC8, + HISTOGRAM_BIND0, + HISTOGRAM_BIND1, + HISTOGRAM_BIND2, + HISTOGRAM_BIND3, + HISTOGRAM_BIND4, + HISTOGRAM_BIND5, + HISTOGRAM_BIND6, + HISTOGRAM_BIND7, + HISTOGRAM_BIND8, + TICKS_CONTRAST_SET, + TIME_CONTRAST_SET, + CONTRAST_BINA0, + CONTRAST_BINA1, + CONTRAST_BINA2, + CONTRAST_BINA3, + CONTRAST_BINA4, + CONTRAST_BINA5, + CONTRAST_BINA6, + CONTRAST_BINA7, + CONTRAST_BINA8, + CONTRAST_BINB0, + CONTRAST_BINB1, + CONTRAST_BINB2, + CONTRAST_BINB3, + CONTRAST_BINB4, + CONTRAST_BINB5, + CONTRAST_BINB6, + CONTRAST_BINB7, + CONTRAST_BINB8, + CONTRAST_BINC0, + CONTRAST_BINC1, + CONTRAST_BINC2, + CONTRAST_BINC3, + CONTRAST_BINC4, + CONTRAST_BINC5, + CONTRAST_BINC6, + CONTRAST_BINC7, + CONTRAST_BINC8, + CONTRAST_BIND0, + CONTRAST_BIND1, + CONTRAST_BIND2, + CONTRAST_BIND3, + CONTRAST_BIND4, + CONTRAST_BIND5, + CONTRAST_BIND6, + CONTRAST_BIND7, + CONTRAST_BIND8, + CHKSUM, + DWL_ID, + DWL_PIXX, + DWL_PIXY, + DWL_X_UNCORRECTED, + DWL_Y_UNCORRECTED, + DWL_X_CORRECTED, + DWL_Y_CORRECTED, + DWL_MAGNITUDE, + DWL_CXA, + DWL_CYA, + DWL_QUALITY, + MATCHEDSTR_ID, + MATCHEDSTR_CAMFPX, + MATCHEDSTR_CAMFPY, + MATCHEDSTR_CAMCARTX, + MATCHEDSTR_CAMCARTY, + MATCHEDSTR_CAMCARTZ, + MATCHEDSTR_CAMMAGNITUDE, + MATCHEDSTR_DBFPX, + MATCHEDSTR_DBFPY, + MATCHEDSTR_DBCARTX, + MATCHEDSTR_DBCARTY, + MATCHEDSTR_DBCARTZ, + MATCHEDSTR_DBMAGNITUDE, + MATCHEDSTR_CATALOGID, + DBIMAGE_ID, + DBIMAGE_PIXX, + DBIMAGE_PIXY, + DBIMAGE_X, + DBIMAGE_Y, + DBIMAGE_MAGNITUDE, + BLOBPIX_ID, + BLOBPIX_X, + BLOBPIX_Y, + BLOBPIX_TOT_VAL, + BLOBPIX_IN_USE, + BLOBPIX_BRIGHT_NEIGHBOURS, + BLOBPIX_REGION, + CAMERA_MODE, + FOCALLENGTH, + EXPOSURE, + INTERVAL, + CAMERA_OFFSET, + PGAGAIN, + ADCGAIN, + CAM_REG1, + CAM_VAL1, + CAM_REG2, + CAM_VAL2, + CAM_REG3, + CAM_VAL3, + CAM_REG4, + CAM_VAL4, + LIMITS_ACTION, + LIMITS_FPGA18CURRENT, + LIMITS_FPGA25CURRENT, + LIMITS_FPGA10CURRENT, + LIMITS_MCUCURRENT, + LIMITS_CMOS21CURRENT, + LIMITS_CMOSPIXCURRENT, + LIMITS_CMOS33CURRENT, + LIMITS_CMOSVRESCURRENT, + LIMITS_CMOSTEMPERATURE, + LIMITS_MCUTEMPERATURE, + BLOB_MODE, + BLOB_MIN_VALUE, + BLOB_MIN_DISTANCE, + BLOB_NEIGHBOUR_DISTANCE, + BLOB_NEIGHBOUR_BRIGHTPIXELS, + BLOB_MIN_TOTAL_VALUE, + BLOB_MAX_TOTAL_VALUE, + BLOB_MIN_BRIGHT_NEIGHBOURS, + BLOB_MAX_BRIGHT_NEIGHBOURS, + BLOB_MAX_PIXELSTOCONSIDER, + BLOB_SIGNAL_THRESHOLD, + BLOB_DARK_THRESHOLD, + BLOB_ENABLE_HISTOGRAM, + BLOB_ENABLE_CONTRAST, + BLOB_BIN_MODE }; static const DeviceCommandId_t PING_REQUEST = 0; @@ -330,1103 +331,943 @@ static const uint8_t BLOB_SET_ENTRIES = 15; // Action, parameter and telemetry IDs namespace ID { - static const uint8_t PING = 0; - static const uint8_t BOOT = 1; - static const uint8_t VERSION = 2; - static const uint8_t INTERFACE = 3; - static const uint8_t LIMITS = 5; - static const uint8_t MOUNTING = 6; - static const uint8_t CAMERA = 9; - static const uint8_t BLOB = 10; - static const uint8_t CENTROIDING = 11; - static const uint8_t LISA = 12; - static const uint8_t MATCHING = 13; - static const uint8_t TRACKING = 14; - static const uint8_t VALIDATION = 15; - static const uint8_t ALGO = 16; - static const uint8_t REBOOT = 7; - static const uint8_t UPLOAD_IMAGE = 10; - static const uint8_t POWER = 11; - static const uint8_t SET_TIME = 14; - static const uint8_t SUBSCRIBE = 18; - static const uint8_t SOLUTION = 24; - static const uint8_t TEMPERATURE = 25; - static const uint8_t HISTOGRAM = 28; - static const uint8_t CONTRAST = 29; - static const uint8_t TIME = 1; - static const uint8_t WRITE = 2; - static const uint8_t READ = 3; - static const uint8_t CHECKSUM = 4; - static const uint8_t ERASE = 5; - static const uint8_t UNLOCK = 6; - static const uint8_t TAKE_IMAGE = 15; - static const uint8_t ERROR_RESET = 12; - static const uint8_t DOWNLOAD_CENTROID = 16; - static const uint8_t UPLOAD_CENTROID = 17; - static const uint8_t DOWNLOAD_MATCHED_STAR = 18; - static const uint8_t DOWNLOAD_DBIMAGE = 19; - static const uint8_t DOWNLOAD_BLOBPIXEL = 24; - static const uint8_t FPGA_ACTION = 22; -} +static const uint8_t PING = 0; +static const uint8_t BOOT = 1; +static const uint8_t VERSION = 2; +static const uint8_t INTERFACE = 3; +static const uint8_t LIMITS = 5; +static const uint8_t MOUNTING = 6; +static const uint8_t CAMERA = 9; +static const uint8_t BLOB = 10; +static const uint8_t CENTROIDING = 11; +static const uint8_t LISA = 12; +static const uint8_t MATCHING = 13; +static const uint8_t TRACKING = 14; +static const uint8_t VALIDATION = 15; +static const uint8_t ALGO = 16; +static const uint8_t REBOOT = 7; +static const uint8_t UPLOAD_IMAGE = 10; +static const uint8_t POWER = 11; +static const uint8_t SET_TIME = 14; +static const uint8_t SUBSCRIBE = 18; +static const uint8_t SOLUTION = 24; +static const uint8_t TEMPERATURE = 25; +static const uint8_t HISTOGRAM = 28; +static const uint8_t CONTRAST = 29; +static const uint8_t TIME = 1; +static const uint8_t WRITE = 2; +static const uint8_t READ = 3; +static const uint8_t CHECKSUM = 4; +static const uint8_t ERASE = 5; +static const uint8_t UNLOCK = 6; +static const uint8_t TAKE_IMAGE = 15; +static const uint8_t ERROR_RESET = 12; +static const uint8_t DOWNLOAD_CENTROID = 16; +static const uint8_t UPLOAD_CENTROID = 17; +static const uint8_t DOWNLOAD_MATCHED_STAR = 18; +static const uint8_t DOWNLOAD_DBIMAGE = 19; +static const uint8_t DOWNLOAD_BLOBPIXEL = 24; +static const uint8_t FPGA_ACTION = 22; +} // namespace ID namespace Program { - static const uint8_t BOOTLOADER = 1; - static const uint8_t FIRMWARE = 2; -} +static const uint8_t BOOTLOADER = 1; +static const uint8_t FIRMWARE = 2; +} // namespace Program /** * @brief This dataset can be used to store the temperature of a reaction wheel. */ -class TemperatureSet: - public StaticLocalDataSet { -public: +class TemperatureSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 20; - static const size_t SIZE = 20; + TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} - TemperatureSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { - } + TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} - TemperatureSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { - } + // Ticks is time reference generated by internal counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_TEMPERATURE_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_TEMPERATURE_SET, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, PoolIds::MCU_TEMPERATURE, this); + lp_var_t cmosTemperature = lp_var_t(sid.objectId, PoolIds::CMOS_TEMPERATURE, this); - // Ticks is time reference generated by internal counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_TEMPERATURE_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_TEMPERATURE_SET, this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, - PoolIds::MCU_TEMPERATURE, this); - lp_var_t cmosTemperature = lp_var_t(sid.objectId, - PoolIds::CMOS_TEMPERATURE, this); - - void printSet() { - sif::info << "TemperatureSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "TemperatureSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "TemperatureSet::printSet: MCU Temperature: " - << this->mcuTemperature << " °C" << std::endl; - sif::info << "TemperatureSet::printSet: CMOS Temperature: " - << this->cmosTemperature << " °C" << std::endl; - } + void printSet() { + sif::info << "TemperatureSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "TemperatureSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "TemperatureSet::printSet: MCU Temperature: " << this->mcuTemperature << " °C" + << std::endl; + sif::info << "TemperatureSet::printSet: CMOS Temperature: " << this->cmosTemperature << " °C" + << std::endl; + } }; /** * @brief Package to store version parameters */ -class VersionSet: - public StaticLocalDataSet { -public: +class VersionSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 15; - static const size_t SIZE = 15; + VersionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, VERSION_SET_ID) {} - VersionSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, VERSION_SET_ID) { - } + VersionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) {} - VersionSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_VERSION_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_VERSION_SET, this); + lp_var_t program = lp_var_t(sid.objectId, PoolIds::PROGRAM, this); + lp_var_t major = lp_var_t(sid.objectId, PoolIds::MAJOR, this); + lp_var_t minor = lp_var_t(sid.objectId, PoolIds::MINOR, this); - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_VERSION_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_VERSION_SET, this); - lp_var_t program = lp_var_t(sid.objectId, - PoolIds::PROGRAM, this); - lp_var_t major = lp_var_t(sid.objectId, - PoolIds::MAJOR, this); - lp_var_t minor = lp_var_t(sid.objectId, - PoolIds::MINOR, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "VersionSet::printSet: Ticks: " - << std::dec << this->ticks << std::endl; - sif::info << "VersionSet::printSet: Unix Time: " - << this->time << " us" << std::endl; - sif::info << "VersionSet::printSet: Program: " - << static_cast(this->program.value) << std::endl; - sif::info << "VersionSet::printSet: Major: " - << static_cast(this->major.value) << std::endl; - sif::info << "VersionSet::printSet: Minor: " - << static_cast(this->minor.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "VersionSet::printSet: Ticks: " << std::dec << this->ticks << std::endl; + sif::info << "VersionSet::printSet: Unix Time: " << this->time << " us" << std::endl; + sif::info << "VersionSet::printSet: Program: " << static_cast(this->program.value) + << std::endl; + sif::info << "VersionSet::printSet: Major: " << static_cast(this->major.value) + << std::endl; + sif::info << "VersionSet::printSet: Minor: " << static_cast(this->minor.value) + << std::endl; + } }; /** * @brief Dataset to store the interface telemtry data. */ -class InterfaceSet: - public StaticLocalDataSet { -public: +class InterfaceSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 20; - static const size_t SIZE = 20; + InterfaceSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} - InterfaceSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, REQ_INTERFACE) { - } + InterfaceSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} - InterfaceSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { - } + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_INTERFACE_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_INTERFACE_SET, this); + lp_var_t frameCount = lp_var_t(sid.objectId, PoolIds::FRAME_COUNT, this); + lp_var_t checksumerrorCount = + lp_var_t(sid.objectId, PoolIds::CHECKSUM_ERROR_COUNT, this); - // Ticks is time reference generated by interanl counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_INTERFACE_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_INTERFACE_SET, this); - lp_var_t frameCount = lp_var_t(sid.objectId, - PoolIds::FRAME_COUNT, this); - lp_var_t checksumerrorCount = lp_var_t(sid.objectId, - PoolIds::CHECKSUM_ERROR_COUNT, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "InterfaceSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "InterfaceSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "InterfaceSet::printSet: Frame Count: " - << this->frameCount << std::endl; - sif::info << "InterfaceSet::printSet: Checksum Error Count: " - << this->checksumerrorCount << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "InterfaceSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "InterfaceSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "InterfaceSet::printSet: Frame Count: " << this->frameCount << std::endl; + sif::info << "InterfaceSet::printSet: Checksum Error Count: " << this->checksumerrorCount + << std::endl; + } }; /** * @brief Dataset to store the data of the power telemetry reply. */ -class PowerSet: - public StaticLocalDataSet { -public: +class PowerSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 76; - static const size_t SIZE = 76; + PowerSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, REQ_INTERFACE) {} - PowerSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, REQ_INTERFACE) { - } + PowerSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) {} - PowerSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, REQ_INTERFACE)) { - } + // Ticks is time reference generated by interanl counter of the star tracker + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_POWER_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_POWER_SET, this); + lp_var_t mcuCurrent = lp_var_t(sid.objectId, PoolIds::MCU_CURRENT, this); + lp_var_t mcuVoltage = lp_var_t(sid.objectId, PoolIds::MCU_VOLTAGE, this); + lp_var_t fpgaCoreCurrent = lp_var_t(sid.objectId, PoolIds::FPGA_CORE_CURRENT, this); + lp_var_t fpgaCoreVoltage = lp_var_t(sid.objectId, PoolIds::FPGA_CORE_VOLTAGE, this); + lp_var_t fpga18Current = lp_var_t(sid.objectId, PoolIds::FPGA_18_CURRENT, this); + lp_var_t fpga18Voltage = lp_var_t(sid.objectId, PoolIds::FPGA_18_VOLTAGE, this); + lp_var_t fpga25Current = lp_var_t(sid.objectId, PoolIds::FPGA_25_CURRENT, this); + lp_var_t fpga25Voltage = lp_var_t(sid.objectId, PoolIds::FPGA_25_VOLTAGE, this); + lp_var_t cmv21Current = lp_var_t(sid.objectId, PoolIds::CMV_21_CURRENT, this); + lp_var_t cmv21Voltage = lp_var_t(sid.objectId, PoolIds::CMV_21_VOLTAGE, this); + lp_var_t cmvPixCurrent = lp_var_t(sid.objectId, PoolIds::CMV_PIX_CURRENT, this); + lp_var_t cmvPixVoltage = lp_var_t(sid.objectId, PoolIds::CMV_PIX_VOLTAGE, this); + lp_var_t cmv33Current = lp_var_t(sid.objectId, PoolIds::CMV_33_CURRENT, this); + lp_var_t cmv33Voltage = lp_var_t(sid.objectId, PoolIds::CMV_33_VOLTAGE, this); + lp_var_t cmvResCurrent = lp_var_t(sid.objectId, PoolIds::CMV_RES_CURRENT, this); + lp_var_t cmvResVoltage = lp_var_t(sid.objectId, PoolIds::CMV_RES_VOLTAGE, this); - // Ticks is time reference generated by interanl counter of the star tracker - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_POWER_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_POWER_SET, this); - lp_var_t mcuCurrent = lp_var_t(sid.objectId, - PoolIds::MCU_CURRENT, this); - lp_var_t mcuVoltage = lp_var_t(sid.objectId, - PoolIds::MCU_VOLTAGE, this); - lp_var_t fpgaCoreCurrent = lp_var_t(sid.objectId, - PoolIds::FPGA_CORE_CURRENT, this); - lp_var_t fpgaCoreVoltage = lp_var_t(sid.objectId, - PoolIds::FPGA_CORE_VOLTAGE, this); - lp_var_t fpga18Current = lp_var_t(sid.objectId, - PoolIds::FPGA_18_CURRENT, this); - lp_var_t fpga18Voltage = lp_var_t(sid.objectId, - PoolIds::FPGA_18_VOLTAGE, this); - lp_var_t fpga25Current = lp_var_t(sid.objectId, - PoolIds::FPGA_25_CURRENT, this); - lp_var_t fpga25Voltage = lp_var_t(sid.objectId, - PoolIds::FPGA_25_VOLTAGE, this); - lp_var_t cmv21Current = lp_var_t(sid.objectId, - PoolIds::CMV_21_CURRENT, this); - lp_var_t cmv21Voltage = lp_var_t(sid.objectId, - PoolIds::CMV_21_VOLTAGE, this); - lp_var_t cmvPixCurrent = lp_var_t(sid.objectId, - PoolIds::CMV_PIX_CURRENT, this); - lp_var_t cmvPixVoltage = lp_var_t(sid.objectId, - PoolIds::CMV_PIX_VOLTAGE, this); - lp_var_t cmv33Current = lp_var_t(sid.objectId, - PoolIds::CMV_33_CURRENT, this); - lp_var_t cmv33Voltage = lp_var_t(sid.objectId, - PoolIds::CMV_33_VOLTAGE, this); - lp_var_t cmvResCurrent = lp_var_t(sid.objectId, - PoolIds::CMV_RES_CURRENT, this); - lp_var_t cmvResVoltage = lp_var_t(sid.objectId, - PoolIds::CMV_RES_VOLTAGE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "PowerSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "PowerSet::printSet: Time: " - << this->time << " us" << std::endl; - sif::info << "PowerSet::printSet: MCU Current: " - << this->mcuCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: MCU Voltage: " - << this->mcuVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA Core current: " - << this->fpgaCoreCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA Core voltage: " - << this->fpgaCoreVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA 18 current: " - << this->fpga18Current << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA 18 voltage: " - << this->fpga18Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: FPGA 25 current: " - << this->fpga25Current << " A" << std::endl; - sif::info << "PowerSet::printSet: FPGA 25 voltage: " - << this->fpga25Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV 21 current: " - << this->cmv21Current << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV 21 voltage: " - << this->cmv21Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV Pix current: " - << this->cmvPixCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV Pix voltage: " - << this->cmvPixVoltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV 33 current: " - << this->cmv33Current << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV 33 voltage: " - << this->cmv33Voltage << " V" << std::endl; - sif::info << "PowerSet::printSet: CMV Res current: " - << this->cmvResCurrent << " A" << std::endl; - sif::info << "PowerSet::printSet: CMV Res voltage: " - << this->cmvResVoltage << " V" << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "PowerSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "PowerSet::printSet: Time: " << this->time << " us" << std::endl; + sif::info << "PowerSet::printSet: MCU Current: " << this->mcuCurrent << " A" << std::endl; + sif::info << "PowerSet::printSet: MCU Voltage: " << this->mcuVoltage << " V" << std::endl; + sif::info << "PowerSet::printSet: FPGA Core current: " << this->fpgaCoreCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA Core voltage: " << this->fpgaCoreVoltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 current: " << this->fpga18Current << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 18 voltage: " << this->fpga18Voltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 current: " << this->fpga25Current << " A" + << std::endl; + sif::info << "PowerSet::printSet: FPGA 25 voltage: " << this->fpga25Voltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: CMV 21 current: " << this->cmv21Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 21 voltage: " << this->cmv21Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Pix current: " << this->cmvPixCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: CMV Pix voltage: " << this->cmvPixVoltage << " V" + << std::endl; + sif::info << "PowerSet::printSet: CMV 33 current: " << this->cmv33Current << " A" << std::endl; + sif::info << "PowerSet::printSet: CMV 33 voltage: " << this->cmv33Voltage << " V" << std::endl; + sif::info << "PowerSet::printSet: CMV Res current: " << this->cmvResCurrent << " A" + << std::endl; + sif::info << "PowerSet::printSet: CMV Res voltage: " << this->cmvResVoltage << " V" + << std::endl; + } }; /** * @brief Data set to store the time telemetry packet. */ -class TimeSet: - public StaticLocalDataSet { -public: +class TimeSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 24; - static const size_t SIZE = 24; + TimeSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TIME_SET_ID) {} - TimeSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TIME_SET_ID) { - } + TimeSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) {} - TimeSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TIME_SET_ID)) { - } - - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_TIME_SET, this); - /** Unix time in microseconds */ - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_TIME_SET, this); - // Number of milliseconds since processor start-up - lp_var_t runTime = lp_var_t(sid.objectId, - PoolIds::RUN_TIME, this); - // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds - lp_var_t unixTime = lp_var_t(sid.objectId, - PoolIds::UNIX_TIME, this); - void printSet() { - PoolReadGuard rg(this); - sif::info << "TimeSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "TimeSet::printSet: Time (time stamp): " - << this->time << " us" << std::endl; - sif::info << "TimeSet::printSet: Run Time: " - << this->runTime << " ms" << std::endl; - sif::info << "TimeSet::printSet: Unix Time: " - << this->unixTime << " s" << std::endl; - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_TIME_SET, this); + /** Unix time in microseconds */ + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_TIME_SET, this); + // Number of milliseconds since processor start-up + lp_var_t runTime = lp_var_t(sid.objectId, PoolIds::RUN_TIME, this); + // Unix time in seconds?? --> maybe typo in datasheet. Seems to be microseconds + lp_var_t unixTime = lp_var_t(sid.objectId, PoolIds::UNIX_TIME, this); + void printSet() { + PoolReadGuard rg(this); + sif::info << "TimeSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "TimeSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "TimeSet::printSet: Run Time: " << this->runTime << " ms" << std::endl; + sif::info << "TimeSet::printSet: Unix Time: " << this->unixTime << " s" << std::endl; + } }; /** * @brief The solution dataset is the main dataset of the star tracker and contains the * attitude information. */ -class SolutionSet: - public StaticLocalDataSet { -public: +class SolutionSet : public StaticLocalDataSet { + public: + static const size_t SIZE = 78; - static const size_t SIZE = 78; + SolutionSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SOLUTION_SET_ID) {} - SolutionSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, SOLUTION_SET_ID) { - } + SolutionSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) {} - SolutionSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, SOLUTION_SET_ID)) { - } + // Ticks timestamp + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_SOLUTION_SET, this); + /// Unix time stamp + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_SOLUTION_SET, this); + // Calibrated quaternion (takes into account the mounting quaternion), typically same as + // track q values + lp_var_t caliQw = lp_var_t(sid.objectId, PoolIds::CALI_QW, this); + lp_var_t caliQx = lp_var_t(sid.objectId, PoolIds::CALI_QX, this); + lp_var_t caliQy = lp_var_t(sid.objectId, PoolIds::CALI_QY, this); + lp_var_t caliQz = lp_var_t(sid.objectId, PoolIds::CALI_QZ, this); + // The lower this value the more confidence that the star tracker solution is correct + lp_var_t trackConfidence = lp_var_t(sid.objectId, PoolIds::TRACK_CONFIDENCE, this); + // Estimated attitude of spacecraft + lp_var_t trackQw = lp_var_t(sid.objectId, PoolIds::TRACK_QW, this); + lp_var_t trackQx = lp_var_t(sid.objectId, PoolIds::TRACK_QX, this); + lp_var_t trackQy = lp_var_t(sid.objectId, PoolIds::TRACK_QY, this); + lp_var_t trackQz = lp_var_t(sid.objectId, PoolIds::TRACK_QZ, this); + // Number of stars removed from tracking solution + lp_var_t trackRemoved = lp_var_t(sid.objectId, PoolIds::TRACK_REMOVED, this); + // Number of stars for which a valid centroid was found + lp_var_t starsCentroided = + lp_var_t(sid.objectId, PoolIds::STARS_CENTROIDED, this); + // Number of stars that matched to a database star + lp_var_t starsMatchedDatabase = + lp_var_t(sid.objectId, PoolIds::STARS_MATCHED_DATABASE, this); + // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of + // attitude + lp_var_t lisaQw = lp_var_t(sid.objectId, PoolIds::LISA_QW, this); + lp_var_t lisaQx = lp_var_t(sid.objectId, PoolIds::LISA_QX, this); + lp_var_t lisaQy = lp_var_t(sid.objectId, PoolIds::LISA_QY, this); + lp_var_t lisaQz = lp_var_t(sid.objectId, PoolIds::LISA_QZ, this); + // Percentage of close stars in LISA solution + lp_var_t lisaPercentageClose = + lp_var_t(sid.objectId, PoolIds::LISA_PERC_CLOSE, this); + // Number of close stars in LISA solution + lp_var_t lisaNrClose = lp_var_t(sid.objectId, PoolIds::LISA_NR_CLOSE, this); + // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) + lp_var_t isTrustWorthy = lp_var_t(sid.objectId, PoolIds::TRUST_WORTHY, this); + // Number of times the validation criteria was met + lp_var_t stableCount = lp_var_t(sid.objectId, PoolIds::STABLE_COUNT, this); + // Shows the autonomous mode used to obtain the star tracker attitude + lp_var_t solutionStrategy = + lp_var_t(sid.objectId, PoolIds::SOLUTION_STRATEGY, this); - // Ticks timestamp - lp_var_t ticks = lp_var_t(sid.objectId, - PoolIds::TICKS_SOLUTION_SET, this); - /// Unix time stamp - lp_var_t time = lp_var_t(sid.objectId, - PoolIds::TIME_SOLUTION_SET, this); - // Calibrated quaternion (takes into account the mounting quaternion), typically same as - // track q values - lp_var_t caliQw = lp_var_t(sid.objectId, PoolIds::CALI_QW, this); - lp_var_t caliQx = lp_var_t(sid.objectId, PoolIds::CALI_QX, this); - lp_var_t caliQy = lp_var_t(sid.objectId, PoolIds::CALI_QY, this); - lp_var_t caliQz = lp_var_t(sid.objectId, PoolIds::CALI_QZ, this); - // The lower this value the more confidence that the star tracker solution is correct - lp_var_t trackConfidence = lp_var_t(sid.objectId, PoolIds::TRACK_CONFIDENCE, - this); - // Estimated attitude of spacecraft - lp_var_t trackQw = lp_var_t(sid.objectId, PoolIds::TRACK_QW, this); - lp_var_t trackQx = lp_var_t(sid.objectId, PoolIds::TRACK_QX, this); - lp_var_t trackQy = lp_var_t(sid.objectId, PoolIds::TRACK_QY, this); - lp_var_t trackQz = lp_var_t(sid.objectId, PoolIds::TRACK_QZ, this); - // Number of stars removed from tracking solution - lp_var_t trackRemoved = lp_var_t(sid.objectId, PoolIds::TRACK_REMOVED, this); - // Number of stars for which a valid centroid was found - lp_var_t starsCentroided = lp_var_t(sid.objectId, PoolIds::STARS_CENTROIDED, - this); - // Number of stars that matched to a database star - lp_var_t starsMatchedDatabase = lp_var_t(sid.objectId, - PoolIds::STARS_MATCHED_DATABASE, this); - // Result of LISA (lost in space algorithm), searches for stars without prior knowledge of - // attitude - lp_var_t lisaQw = lp_var_t(sid.objectId, PoolIds::LISA_QW, this); - lp_var_t lisaQx = lp_var_t(sid.objectId, PoolIds::LISA_QX, this); - lp_var_t lisaQy = lp_var_t(sid.objectId, PoolIds::LISA_QY, this); - lp_var_t lisaQz = lp_var_t(sid.objectId, PoolIds::LISA_QZ, this); - // Percentage of close stars in LISA solution - lp_var_t lisaPercentageClose = lp_var_t(sid.objectId, PoolIds::LISA_PERC_CLOSE, - this); - // Number of close stars in LISA solution - lp_var_t lisaNrClose = lp_var_t(sid.objectId, PoolIds::LISA_NR_CLOSE, this); - // Gives a combined overview of the validation parameters (1 for valid solution, otherwise 0) - lp_var_t isTrustWorthy = lp_var_t(sid.objectId, PoolIds::TRUST_WORTHY, this); - // Number of times the validation criteria was met - lp_var_t stableCount = lp_var_t(sid.objectId, PoolIds::STABLE_COUNT, this); - // Shows the autonomous mode used to obtain the star tracker attitude - lp_var_t solutionStrategy = lp_var_t(sid.objectId, PoolIds::SOLUTION_STRATEGY, - this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "SolutionSet::printSet: Ticks: " - << this->ticks << std::endl; - sif::info << "SolutionSet::printSet: Time: " - << this->time << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qw: " - << this->caliQw << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qx: " - << this->caliQx << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qy: " - << this->caliQy << std::endl; - sif::info << "SolutionSet::printSet: Calibrated quaternion Qz: " - << this->caliQz << std::endl; - sif::info << "SolutionSet::printSet: Track confidence: " - << this->trackConfidence << std::endl; - sif::info << "SolutionSet::printSet: Track Qw: " - << this->trackQw << std::endl; - sif::info << "SolutionSet::printSet: Track Qx: " - << this->trackQx << std::endl; - sif::info << "SolutionSet::printSet: Track Qy: " - << this->trackQy << std::endl; - sif::info << "SolutionSet::printSet: Track Qz: " - << this->trackQz << std::endl; - sif::info << "SolutionSet::printSet: Track removed: " - << static_cast(this->trackRemoved.value) << std::endl; - sif::info << "SolutionSet::printSet: Number of stars centroided: " - << static_cast(this->starsCentroided.value) << std::endl; - sif::info << "SolutionSet::printSet: Number of stars matched database: " - << static_cast(this->starsMatchedDatabase.value) << std::endl; - sif::info << "SolutionSet::printSet: LISA Qw: " - << this->lisaQw << std::endl; - sif::info << "SolutionSet::printSet: LISA Qx: " - << this->lisaQx << std::endl; - sif::info << "SolutionSet::printSet: LISA Qy: " - << this->lisaQy << std::endl; - sif::info << "SolutionSet::printSet: LISA Qz: " - << this->lisaQz << std::endl; - sif::info << "SolutionSet::printSet: LISA Percentage close: " - << this->lisaPercentageClose << std::endl; - sif::info << "SolutionSet::printSet: LISA number of close stars: " - << static_cast(this->lisaNrClose.value) << std::endl; - sif::info << "SolutionSet::printSet: Is trust worthy: " - << static_cast(this->isTrustWorthy.value) << std::endl; - sif::info << "SolutionSet::printSet: Stable count: " - << this->stableCount << std::endl; - sif::info << "SolutionSet::printSet: Solution strategy: " - << static_cast(this->solutionStrategy.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "SolutionSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "SolutionSet::printSet: Time: " << this->time << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qw: " << this->caliQw << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qx: " << this->caliQx << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qy: " << this->caliQy << std::endl; + sif::info << "SolutionSet::printSet: Calibrated quaternion Qz: " << this->caliQz << std::endl; + sif::info << "SolutionSet::printSet: Track confidence: " << this->trackConfidence << std::endl; + sif::info << "SolutionSet::printSet: Track Qw: " << this->trackQw << std::endl; + sif::info << "SolutionSet::printSet: Track Qx: " << this->trackQx << std::endl; + sif::info << "SolutionSet::printSet: Track Qy: " << this->trackQy << std::endl; + sif::info << "SolutionSet::printSet: Track Qz: " << this->trackQz << std::endl; + sif::info << "SolutionSet::printSet: Track removed: " + << static_cast(this->trackRemoved.value) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars centroided: " + << static_cast(this->starsCentroided.value) << std::endl; + sif::info << "SolutionSet::printSet: Number of stars matched database: " + << static_cast(this->starsMatchedDatabase.value) << std::endl; + sif::info << "SolutionSet::printSet: LISA Qw: " << this->lisaQw << std::endl; + sif::info << "SolutionSet::printSet: LISA Qx: " << this->lisaQx << std::endl; + sif::info << "SolutionSet::printSet: LISA Qy: " << this->lisaQy << std::endl; + sif::info << "SolutionSet::printSet: LISA Qz: " << this->lisaQz << std::endl; + sif::info << "SolutionSet::printSet: LISA Percentage close: " << this->lisaPercentageClose + << std::endl; + sif::info << "SolutionSet::printSet: LISA number of close stars: " + << static_cast(this->lisaNrClose.value) << std::endl; + sif::info << "SolutionSet::printSet: Is trust worthy: " + << static_cast(this->isTrustWorthy.value) << std::endl; + sif::info << "SolutionSet::printSet: Stable count: " << this->stableCount << std::endl; + sif::info << "SolutionSet::printSet: Solution strategy: " + << static_cast(this->solutionStrategy.value) << std::endl; + } }; /** * @brief Dataset to store the histogram */ -class HistogramSet: - public StaticLocalDataSet { -public: +class HistogramSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + HistogramSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HISTOGRAM_SET_ID) {} - HistogramSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HISTOGRAM_SET_ID) { - } + HistogramSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HISTOGRAM_SET_ID)) {} - HistogramSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HISTOGRAM_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_HISTOGRAM_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_HISTOGRAM_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); + lp_var_t binB0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND8, this); - lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_HISTOGRAM_SET, this); - lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_HISTOGRAM_SET, this); - lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA0, this); - lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA1, this); - lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA2, this); - lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA3, this); - lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA4, this); - lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA5, this); - lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA6, this); - lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA7, this); - lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINA8, this); - lp_var_t binB0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB0, this); - lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB1, this); - lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB2, this); - lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB3, this); - lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB4, this); - lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB5, this); - lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB6, this); - lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB7, this); - lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINB8, this); - lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC0, this); - lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC1, this); - lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC2, this); - lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC3, this); - lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC4, this); - lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC5, this); - lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC6, this); - lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC7, this); - lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BINC8, this); - lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND0, this); - lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND1, this); - lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND2, this); - lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND3, this); - lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND4, this); - lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND5, this); - lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND6, this); - lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND7, this); - lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::HISTOGRAM_BIND8, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "HistogramSet::printSet: Ticks: " << this->ticks << std::endl; - sif::info << "HistogramSet::printSet: Time (time stamp): " << this->time << " us" - << std::endl; - sif::info << "HistogramSet::printSet: BinA0: " << this->binA0 << std::endl; - sif::info << "HistogramSet::printSet: BinA1: " << this->binA1 << std::endl; - sif::info << "HistogramSet::printSet: BinA2: " << this->binA2 << std::endl; - sif::info << "HistogramSet::printSet: BinA3: " << this->binA3 << std::endl; - sif::info << "HistogramSet::printSet: BinA4: " << this->binA4 << std::endl; - sif::info << "HistogramSet::printSet: BinA5: " << this->binA5 << std::endl; - sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; - sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; - sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "HistogramSet::printSet: BinB0: " << this->binB0 << std::endl; - sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; - sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; - sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; - sif::info << "HistogramSet::printSet: BinB4: " << this->binB4 << std::endl; - sif::info << "HistogramSet::printSet: BinB5: " << this->binB5 << std::endl; - sif::info << "HistogramSet::printSet: BinB6: " << this->binB6 << std::endl; - sif::info << "HistogramSet::printSet: BinB7: " << this->binB7 << std::endl; - sif::info << "HistogramSet::printSet: BinB8: " << this->binB8 << std::endl; - sif::info << "HistogramSet::printSet: BinC0: " << this->binC0 << std::endl; - sif::info << "HistogramSet::printSet: BinC1: " << this->binC1 << std::endl; - sif::info << "HistogramSet::printSet: BinC2: " << this->binC2 << std::endl; - sif::info << "HistogramSet::printSet: BinC3: " << this->binC3 << std::endl; - sif::info << "HistogramSet::printSet: BinC4: " << this->binC4 << std::endl; - sif::info << "HistogramSet::printSet: BinC5: " << this->binC5 << std::endl; - sif::info << "HistogramSet::printSet: BinC6: " << this->binC6 << std::endl; - sif::info << "HistogramSet::printSet: BinC7: " << this->binC7 << std::endl; - sif::info << "HistogramSet::printSet: BinC8: " << this->binC8 << std::endl; - sif::info << "HistogramSet::printSet: BinD0: " << this->binD0 << std::endl; - sif::info << "HistogramSet::printSet: BinD1: " << this->binD1 << std::endl; - sif::info << "HistogramSet::printSet: BinD2: " << this->binD2 << std::endl; - sif::info << "HistogramSet::printSet: BinD3: " << this->binD3 << std::endl; - sif::info << "HistogramSet::printSet: BinD4: " << this->binD4 << std::endl; - sif::info << "HistogramSet::printSet: BinD5: " << this->binD5 << std::endl; - sif::info << "HistogramSet::printSet: BinD6: " << this->binD6 << std::endl; - sif::info << "HistogramSet::printSet: BinD7: " << this->binD7 << std::endl; - sif::info << "HistogramSet::printSet: BinD8: " << this->binD8 << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "HistogramSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "HistogramSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "HistogramSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "HistogramSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "HistogramSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "HistogramSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "HistogramSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "HistogramSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "HistogramSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "HistogramSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "HistogramSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "HistogramSet::printSet: BinB0: " << this->binB0 << std::endl; + sif::info << "HistogramSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "HistogramSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "HistogramSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "HistogramSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "HistogramSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "HistogramSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "HistogramSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "HistogramSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "HistogramSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "HistogramSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "HistogramSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "HistogramSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "HistogramSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "HistogramSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "HistogramSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "HistogramSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "HistogramSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "HistogramSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "HistogramSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "HistogramSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "HistogramSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "HistogramSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "HistogramSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "HistogramSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "HistogramSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "HistogramSet::printSet: BinD8: " << this->binD8 << std::endl; + } }; /** * @brief Dataset to store the contrast telemetry data */ -class ContrastSet: - public StaticLocalDataSet { -public: +class ContrastSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + ContrastSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CONTRAST_SET_ID) {} - ContrastSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, CONTRAST_SET_ID) { - } + ContrastSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) {} - ContrastSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) { - } + lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); + lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); + lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); + lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); + lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); + lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); + lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); + lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); + lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); + lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); + lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); + lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); + lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); + lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); + lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); + lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); + lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); + lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); + lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); + lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); + lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); + lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); + lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); + lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); + lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); + lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); + lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); + lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); + lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); + lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); + lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); + lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); + lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); + lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); + lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); + lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); + lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); + lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); - lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); - lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); - lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); - lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); - lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); - lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); - lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); - lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); - lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); - lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); - lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); - lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); - lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); - lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); - lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); - lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); - lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); - lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); - lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); - lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); - lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); - lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); - lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); - lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); - lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); - lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); - lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); - lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); - lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); - lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); - lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); - lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); - lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); - lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); - lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); - lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); - lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); - lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; - sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" - << std::endl; - sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; - sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; - sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; - sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; - sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; - sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; - sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; - sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; - sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; - sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; - sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; - sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; - sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; - sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; - sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; - sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; - sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; - sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; - sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; - sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; - sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; - sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; - sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; - sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; - sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; - sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; - sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; - sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; - sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; - sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; - sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; - sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; - sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; + sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; + sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; + sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; + sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; + sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; + sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; + sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; + sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; + sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; + sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; + sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; + sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; + sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; + sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; + sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; + sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; + sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; + sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; + sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; + sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; + sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; + sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; + sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; + sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; + sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; + sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; + sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; + sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; + sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; + sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; + sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; + sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; + sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; + sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; + sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; + sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; + } }; /** * @brief Helper Class to extract information from bytestream. */ class ChecksumReply { -public: - - /** - * @brief Constructor - * - * @param datafield Pointer to datafield in reply buffer - * - */ - ChecksumReply(const uint8_t* datafield) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - region = *(datafield); - const uint8_t* addressData = datafield + ADDRESS_OFFSET; - size_t size = sizeof(address); - result = SerializeAdapter::deSerialize(&address, &addressData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address" - << std::endl; - } - const uint8_t* lengthData = datafield + LENGTH_OFFSET; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &lengthData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length" - << std::endl; - } - const uint8_t* checksumData = datafield + CHECKSUM_OFFSET; - size = sizeof(checksum); - result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size, - SerializeIF::Endianness::LITTLE); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum" - << std::endl; - } + public: + /** + * @brief Constructor + * + * @param datafield Pointer to datafield in reply buffer + * + */ + ChecksumReply(const uint8_t* datafield) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + region = *(datafield); + const uint8_t* addressData = datafield + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = SerializeAdapter::deSerialize(&address, &addressData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize address" << std::endl; } - - uint8_t getRegion() { - return region; + const uint8_t* lengthData = datafield + LENGTH_OFFSET; + size = sizeof(length); + result = + SerializeAdapter::deSerialize(&length, &lengthData, &size, SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize length" << std::endl; } - - uint32_t getAddress() { - return address; + const uint8_t* checksumData = datafield + CHECKSUM_OFFSET; + size = sizeof(checksum); + result = SerializeAdapter::deSerialize(&checksum, &checksumData, &size, + SerializeIF::Endianness::LITTLE); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "ChecksumReply::ChecksumReply: Failed to deserialize checksum" << std::endl; } + } - uint32_t getLength() { - return length; - } + uint8_t getRegion() { return region; } - uint32_t getChecksum() { - return checksum; - } + uint32_t getAddress() { return address; } - void printChecksum() { - sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl; - } + uint32_t getLength() { return length; } -private: + uint32_t getChecksum() { return checksum; } - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - static const uint8_t CHECKSUM_OFFSET = 9; + void printChecksum() { + sif::info << "ChecksumReply::printChecksum: 0x" << std::hex << checksum << std::endl; + } - uint8_t region = 0; - uint32_t address = 0; - uint32_t length = 0; - uint32_t checksum = 0; + private: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t CHECKSUM_OFFSET = 9; + + uint8_t region = 0; + uint32_t address = 0; + uint32_t length = 0; + uint32_t checksum = 0; }; class EraseReply { -public: - EraseReply(const uint8_t* datafield) { - region = *datafield; - } + public: + EraseReply(const uint8_t* datafield) { region = *datafield; } - uint8_t getRegion() { - return region; - } + uint8_t getRegion() { return region; } -private: - uint8_t region = 0; + private: + uint8_t region = 0; }; -class ChecksumSet: - public StaticLocalDataSet { -public: +class ChecksumSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 156; - // Size of dataset - static const size_t SIZE = 156; + ChecksumSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CHECKSUM_SET_ID) {} - ChecksumSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, CHECKSUM_SET_ID) { - } + ChecksumSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) {} - ChecksumSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, CHECKSUM_SET_ID)) { - } - - lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); + lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); }; /** * @brief Dataset to store download centroid response */ -class DownloadCentroidSet: - public StaticLocalDataSet { -public: +class DownloadCentroidSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 38; - // Size of dataset - static const size_t SIZE = 38; + DownloadCentroidSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) {} - DownloadCentroidSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) { - } + DownloadCentroidSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) {} - DownloadCentroidSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); + lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); + lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); + lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); + lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); + lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); + lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); + lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); - lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); - lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); - lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); - lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); - lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); - lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); - lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadCentroidSet::printSet: id: " << static_cast(this->id.value) - << std::endl; - sif::info << "DownloadCentroidSet::printSet: pixx: " << this->pixx << std::endl; - sif::info << "DownloadCentroidSet::printSet: pixy: " << this->pixy << std::endl; - sif::info << "DownloadCentroidSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; - sif::info << "DownloadCentroidSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; - sif::info << "DownloadCentroidSet::printSet: xCorrected: " << this->xCorrected << std::endl; - sif::info << "DownloadCentroidSet::printSet: yCorrected: " << this->yCorrected << std::endl; - sif::info << "DownloadCentroidSet::printSet: magnitude: " << this->magnitude << std::endl; - sif::info << "DownloadCentroidSet::printSet: cxa: " << this->cxa << std::endl; - sif::info << "DownloadCentroidSet::printSet: cya: " << this->cya << std::endl; - sif::info << "DownloadCentroidSet::printSet: quality: " << this->quality << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadCentroidSet::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadCentroidSet::printSet: pixx: " << this->pixx << std::endl; + sif::info << "DownloadCentroidSet::printSet: pixy: " << this->pixy << std::endl; + sif::info << "DownloadCentroidSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; + sif::info << "DownloadCentroidSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; + sif::info << "DownloadCentroidSet::printSet: xCorrected: " << this->xCorrected << std::endl; + sif::info << "DownloadCentroidSet::printSet: yCorrected: " << this->yCorrected << std::endl; + sif::info << "DownloadCentroidSet::printSet: magnitude: " << this->magnitude << std::endl; + sif::info << "DownloadCentroidSet::printSet: cxa: " << this->cxa << std::endl; + sif::info << "DownloadCentroidSet::printSet: cya: " << this->cya << std::endl; + sif::info << "DownloadCentroidSet::printSet: quality: " << this->quality << std::endl; + } }; namespace UploadCentroidKeys { - static const char id[] = "id"; - static const char pixx[] = "pixx"; - static const char pixy[] = "pixy"; - static const char x_uncorrected[] = "x_uncorrected"; - static const char y_uncorrected[] = "y_uncorrected"; - static const char x_corrected[] = "x_corrected"; - static const char y_corrected[] = "y_corrected"; - static const char magnitude[] = "magnitude"; - static const char cxa[] = "cxa"; - static const char cya[] = "cya"; - static const char quality[] = "quality"; -}; +static const char id[] = "id"; +static const char pixx[] = "pixx"; +static const char pixy[] = "pixy"; +static const char x_uncorrected[] = "x_uncorrected"; +static const char y_uncorrected[] = "y_uncorrected"; +static const char x_corrected[] = "x_corrected"; +static const char y_corrected[] = "y_corrected"; +static const char magnitude[] = "magnitude"; +static const char cxa[] = "cxa"; +static const char cya[] = "cya"; +static const char quality[] = "quality"; +}; // namespace UploadCentroidKeys /** * @brief Dataset to store matched star information */ -class DownloadMatchedStar : - public StaticLocalDataSet { -public: +class DownloadMatchedStar : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 53; - // Size of dataset - static const size_t SIZE = 53; + DownloadMatchedStar(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) {} - DownloadMatchedStar(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) { - } + DownloadMatchedStar(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) {} - DownloadMatchedStar(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); + lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); + lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); + lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); + lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); + lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); + lp_var_t cammagnitude = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, this); + lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); + lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); + lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); + lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); + lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); + lp_var_t dbmagnitude = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, this); + lp_var_t catalogid = + lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); - lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); - lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); - lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); - lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); - lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); - lp_var_t cammagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, - this); - lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); - lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); - lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); - lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); - lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); - lp_var_t dbmagnitude = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, - this); - lp_var_t catalogid = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, - this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadMatchedStar::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude - << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude - << std::endl; - sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadMatchedStar::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; + sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude << std::endl; + sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; + } }; /** * @brief Dataset to store the response to the DownloadDBImage request */ -class DownloadDBImage : - public StaticLocalDataSet { -public: +class DownloadDBImage : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 21; - // Size of dataset - static const size_t SIZE = 21; + DownloadDBImage(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) {} - DownloadDBImage(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) { - } + DownloadDBImage(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) {} - DownloadDBImage(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); + lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); + lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); + lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadDBImage::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; - sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; - sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; - sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; - sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadDBImage::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; + sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; + sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; + sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; + sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; + } }; /** * @brief Dataset to store the response to the download blob pixel action request */ -class DownloadBlobPixel: public StaticLocalDataSet { -public: +class DownloadBlobPixel : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 22; - // Size of dataset - static const size_t SIZE = 22; + DownloadBlobPixel(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) {} - DownloadBlobPixel(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) { - } + DownloadBlobPixel(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) {} - DownloadBlobPixel(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) { - } + lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); + lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); + lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); + lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); + lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); + lp_var_t brightNeighbours = + lp_var_t(sid.objectId, PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); + lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); - lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); - lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); - lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); - lp_var_t brightNeighbours = lp_var_t(sid.objectId, - PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); - lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadBlobPixel::printSet: id: " - << static_cast(this->id.value) << std::endl; - sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; - sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; - sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; - sif::info << "DownloadBlobPixel::printSet: inUse: " - << static_cast(this->inUse.value) << std::endl; - sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours - << std::endl; - sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "DownloadBlobPixel::printSet: id: " << static_cast(this->id.value) + << std::endl; + sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; + sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; + sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; + sif::info << "DownloadBlobPixel::printSet: inUse: " + << static_cast(this->inUse.value) << std::endl; + sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours + << std::endl; + sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; + } }; /** * @brief Will store the camera parameters set in the star tracker which are retrieved with * a get parameter request. */ -class CameraSet: public StaticLocalDataSet { -public: +class CameraSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 25; - // Size of dataset - static const size_t SIZE = 25; + CameraSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CAMERA_SET_ID) {} - CameraSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, CAMERA_SET_ID) { - } + CameraSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CAMERA_SET_ID)) {} - CameraSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, CAMERA_SET_ID)) { - } + lp_var_t mode = lp_var_t(sid.objectId, PoolIds::CAMERA_MODE, this); + lp_var_t focallength = lp_var_t(sid.objectId, PoolIds::FOCALLENGTH, this); + lp_var_t exposure = lp_var_t(sid.objectId, PoolIds::EXPOSURE, this); + lp_var_t interval = lp_var_t(sid.objectId, PoolIds::INTERVAL, this); + lp_var_t offset = lp_var_t(sid.objectId, PoolIds::CAMERA_OFFSET, this); + lp_var_t pgagain = lp_var_t(sid.objectId, PoolIds::PGAGAIN, this); + lp_var_t adcgain = lp_var_t(sid.objectId, PoolIds::ADCGAIN, this); + lp_var_t reg1 = lp_var_t(sid.objectId, PoolIds::CAM_REG1, this); + lp_var_t val1 = lp_var_t(sid.objectId, PoolIds::CAM_VAL1, this); + lp_var_t reg2 = lp_var_t(sid.objectId, PoolIds::CAM_REG2, this); + lp_var_t val2 = lp_var_t(sid.objectId, PoolIds::CAM_VAL2, this); + lp_var_t reg3 = lp_var_t(sid.objectId, PoolIds::CAM_REG3, this); + lp_var_t val3 = lp_var_t(sid.objectId, PoolIds::CAM_VAL3, this); + lp_var_t reg4 = lp_var_t(sid.objectId, PoolIds::CAM_REG4, this); + lp_var_t val4 = lp_var_t(sid.objectId, PoolIds::CAM_VAL4, this); - lp_var_t mode = lp_var_t(sid.objectId, PoolIds::CAMERA_MODE, this); - lp_var_t focallength = lp_var_t(sid.objectId, PoolIds::FOCALLENGTH, this); - lp_var_t exposure = lp_var_t(sid.objectId, PoolIds::EXPOSURE, this); - lp_var_t interval = lp_var_t(sid.objectId, PoolIds::INTERVAL, this); - lp_var_t offset = lp_var_t(sid.objectId, PoolIds::CAMERA_OFFSET, this); - lp_var_t pgagain = lp_var_t(sid.objectId, PoolIds::PGAGAIN, this); - lp_var_t adcgain = lp_var_t(sid.objectId, PoolIds::ADCGAIN, this); - lp_var_t reg1 = lp_var_t(sid.objectId, PoolIds::CAM_REG1, this); - lp_var_t val1 = lp_var_t(sid.objectId, PoolIds::CAM_VAL1, this); - lp_var_t reg2 = lp_var_t(sid.objectId, PoolIds::CAM_REG2, this); - lp_var_t val2 = lp_var_t(sid.objectId, PoolIds::CAM_VAL2, this); - lp_var_t reg3 = lp_var_t(sid.objectId, PoolIds::CAM_REG3, this); - lp_var_t val3 = lp_var_t(sid.objectId, PoolIds::CAM_VAL3, this); - lp_var_t reg4 = lp_var_t(sid.objectId, PoolIds::CAM_REG4, this); - lp_var_t val4 = lp_var_t(sid.objectId, PoolIds::CAM_VAL4, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "CameraSet::printSet: mode: " << static_cast(this->mode.value) - << std::endl; - sif::info << "CameraSet::printSet: focallength: " << this->focallength << std::endl; - sif::info << "CameraSet::printSet: exposure: " << this->exposure << std::endl; - sif::info << "CameraSet::printSet: interval: " << this->interval << std::endl; - sif::info << "CameraSet::printSet: offset: " << this->offset << std::endl; - sif::info << "CameraSet::printSet: PGA gain: " - << static_cast(this->pgagain.value) << std::endl; - sif::info << "CameraSet::printSet: ADC gain: " - << static_cast(this->adcgain.value) << std::endl; - sif::info << "CameraSet::printSet: Reg 1: " - << static_cast(this->reg1.value) << std::endl; - sif::info << "CameraSet::printSet: Val 1: " - << static_cast(this->val1.value) << std::endl; - sif::info << "CameraSet::printSet: Reg 2: " - << static_cast(this->reg2.value) << std::endl; - sif::info << "CameraSet::printSet: Val 2: " - << static_cast(this->val2.value) << std::endl; - sif::info << "CameraSet::printSet: Reg 3: " - << static_cast(this->reg3.value) << std::endl; - sif::info << "CameraSet::printSet: Val 3: " - << static_cast(this->val3.value) << std::endl; - sif::info << "CameraSet::printSet: Reg 4: " - << static_cast(this->reg4.value) << std::endl; - sif::info << "CameraSet::printSet: Val 4: " - << static_cast(this->val4.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "CameraSet::printSet: mode: " << static_cast(this->mode.value) + << std::endl; + sif::info << "CameraSet::printSet: focallength: " << this->focallength << std::endl; + sif::info << "CameraSet::printSet: exposure: " << this->exposure << std::endl; + sif::info << "CameraSet::printSet: interval: " << this->interval << std::endl; + sif::info << "CameraSet::printSet: offset: " << this->offset << std::endl; + sif::info << "CameraSet::printSet: PGA gain: " << static_cast(this->pgagain.value) + << std::endl; + sif::info << "CameraSet::printSet: ADC gain: " << static_cast(this->adcgain.value) + << std::endl; + sif::info << "CameraSet::printSet: Reg 1: " << static_cast(this->reg1.value) + << std::endl; + sif::info << "CameraSet::printSet: Val 1: " << static_cast(this->val1.value) + << std::endl; + sif::info << "CameraSet::printSet: Reg 2: " << static_cast(this->reg2.value) + << std::endl; + sif::info << "CameraSet::printSet: Val 2: " << static_cast(this->val2.value) + << std::endl; + sif::info << "CameraSet::printSet: Reg 3: " << static_cast(this->reg3.value) + << std::endl; + sif::info << "CameraSet::printSet: Val 3: " << static_cast(this->val3.value) + << std::endl; + sif::info << "CameraSet::printSet: Reg 4: " << static_cast(this->reg4.value) + << std::endl; + sif::info << "CameraSet::printSet: Val 4: " << static_cast(this->val4.value) + << std::endl; + } }; /** * @brief Will store the requested limits */ -class LimitsSet: public StaticLocalDataSet { -public: +class LimitsSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 41; - // Size of dataset - static const size_t SIZE = 41; + LimitsSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LIMITS_SET_ID) {} - LimitsSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, LIMITS_SET_ID) { - } + LimitsSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LIMITS_SET_ID)) {} - LimitsSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, LIMITS_SET_ID)) { - } + lp_var_t action = lp_var_t(sid.objectId, PoolIds::LIMITS_ACTION, this); + lp_var_t fpga18current = + lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA18CURRENT, this); + lp_var_t fpga25current = + lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA25CURRENT, this); + lp_var_t fpga10current = + lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA10CURRENT, this); + lp_var_t mcuCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_MCUCURRENT, this); + lp_var_t cmos21current = + lp_var_t(sid.objectId, PoolIds::LIMITS_CMOS21CURRENT, this); + lp_var_t cmosPixCurrent = + lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSPIXCURRENT, this); + lp_var_t cmos33current = + lp_var_t(sid.objectId, PoolIds::LIMITS_CMOS33CURRENT, this); + lp_var_t cmosVresCurrent = + lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSVRESCURRENT, this); + lp_var_t cmosTemperature = + lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSTEMPERATURE, this); - lp_var_t action = lp_var_t(sid.objectId, PoolIds::LIMITS_ACTION, this); - lp_var_t fpga18current = lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA18CURRENT, this); - lp_var_t fpga25current = lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA25CURRENT, this); - lp_var_t fpga10current = lp_var_t(sid.objectId, PoolIds::LIMITS_FPGA10CURRENT, this); - lp_var_t mcuCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_MCUCURRENT, this); - lp_var_t cmos21current = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOS21CURRENT, this); - lp_var_t cmosPixCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSPIXCURRENT, this); - lp_var_t cmos33current = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOS33CURRENT, this); - lp_var_t cmosVresCurrent = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSVRESCURRENT, this); - lp_var_t cmosTemperature = lp_var_t(sid.objectId, PoolIds::LIMITS_CMOSTEMPERATURE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "CameraSet::printSet: action: " << static_cast(this->action.value) - << std::endl; - sif::info << "CameraSet::printSet: FPGA18Current: " << this->fpga18current << std::endl; - sif::info << "CameraSet::printSet: FPGA25Current: " << this->fpga25current << std::endl; - sif::info << "CameraSet::printSet: FPGA10Current: " << this->fpga10current << std::endl; - sif::info << "CameraSet::printSet: MCUCurrent: " << this->mcuCurrent << std::endl; - sif::info << "CameraSet::printSet: CMOS21Current: " << this->cmos21current << std::endl; - sif::info << "CameraSet::printSet: CMOSPixCurrent: " << this->cmosPixCurrent << std::endl; - sif::info << "CameraSet::printSet: CMOS33Current: " << this->cmos33current << std::endl; - sif::info << "CameraSet::printSet: CMOSVResCurrent: " << this->cmosVresCurrent << std::endl; - sif::info << "CameraSet::printSet: CMOSTemperature: " << this->cmosTemperature << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "CameraSet::printSet: action: " << static_cast(this->action.value) + << std::endl; + sif::info << "CameraSet::printSet: FPGA18Current: " << this->fpga18current << std::endl; + sif::info << "CameraSet::printSet: FPGA25Current: " << this->fpga25current << std::endl; + sif::info << "CameraSet::printSet: FPGA10Current: " << this->fpga10current << std::endl; + sif::info << "CameraSet::printSet: MCUCurrent: " << this->mcuCurrent << std::endl; + sif::info << "CameraSet::printSet: CMOS21Current: " << this->cmos21current << std::endl; + sif::info << "CameraSet::printSet: CMOSPixCurrent: " << this->cmosPixCurrent << std::endl; + sif::info << "CameraSet::printSet: CMOS33Current: " << this->cmos33current << std::endl; + sif::info << "CameraSet::printSet: CMOSVResCurrent: " << this->cmosVresCurrent << std::endl; + sif::info << "CameraSet::printSet: CMOSTemperature: " << this->cmosTemperature << std::endl; + } }; /** * @brief Will store the request of the blob parameters. */ -class BlobSet: public StaticLocalDataSet { -public: +class BlobSet : public StaticLocalDataSet { + public: + // Size of dataset + static const size_t SIZE = 22; - // Size of dataset - static const size_t SIZE = 22; + BlobSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BLOB_SET_ID) {} - BlobSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, BLOB_SET_ID) { - } + BlobSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, BLOB_SET_ID)) {} - BlobSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, BLOB_SET_ID)) { - } + lp_var_t mode = lp_var_t(sid.objectId, PoolIds::BLOB_MODE, this); + lp_var_t minValue = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_VALUE, this); + lp_var_t minDistance = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_DISTANCE, this); + lp_var_t neighbourDistance = + lp_var_t(sid.objectId, PoolIds::BLOB_NEIGHBOUR_DISTANCE, this); + lp_var_t neighbourBrightPixels = + lp_var_t(sid.objectId, PoolIds::BLOB_NEIGHBOUR_BRIGHTPIXELS, this); + lp_var_t minTotalValue = + lp_var_t(sid.objectId, PoolIds::BLOB_MIN_TOTAL_VALUE, this); + lp_var_t maxTotalValue = + lp_var_t(sid.objectId, PoolIds::BLOB_MAX_TOTAL_VALUE, this); + lp_var_t minBrightNeighbours = + lp_var_t(sid.objectId, PoolIds::BLOB_MIN_BRIGHT_NEIGHBOURS, this); + lp_var_t maxBrightNeighbours = + lp_var_t(sid.objectId, PoolIds::BLOB_MAX_BRIGHT_NEIGHBOURS, this); + lp_var_t maxPixelsToConsider = + lp_var_t(sid.objectId, PoolIds::BLOB_MAX_PIXELSTOCONSIDER, this); + lp_var_t signalThreshold = + lp_var_t(sid.objectId, PoolIds::BLOB_SIGNAL_THRESHOLD, this); + lp_var_t darkThreshold = + lp_var_t(sid.objectId, PoolIds::BLOB_DARK_THRESHOLD, this); + lp_var_t enableContrast = + lp_var_t(sid.objectId, PoolIds::BLOB_ENABLE_CONTRAST, this); + lp_var_t enableBinMode = lp_var_t(sid.objectId, PoolIds::BLOB_BIN_MODE, this); - lp_var_t mode = lp_var_t(sid.objectId, PoolIds::BLOB_MODE, this); - lp_var_t minValue = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_VALUE, this); - lp_var_t minDistance = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_DISTANCE, this); - lp_var_t neighbourDistance = lp_var_t(sid.objectId, PoolIds::BLOB_NEIGHBOUR_DISTANCE, this); - lp_var_t neighbourBrightPixels = lp_var_t(sid.objectId, PoolIds::BLOB_NEIGHBOUR_BRIGHTPIXELS, this); - lp_var_t minTotalValue = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_TOTAL_VALUE, this); - lp_var_t maxTotalValue = lp_var_t(sid.objectId, PoolIds::BLOB_MAX_TOTAL_VALUE, this); - lp_var_t minBrightNeighbours = lp_var_t(sid.objectId, PoolIds::BLOB_MIN_BRIGHT_NEIGHBOURS, this); - lp_var_t maxBrightNeighbours = lp_var_t(sid.objectId, PoolIds::BLOB_MAX_BRIGHT_NEIGHBOURS, this); - lp_var_t maxPixelsToConsider = lp_var_t(sid.objectId, PoolIds::BLOB_MAX_PIXELSTOCONSIDER, this); - lp_var_t signalThreshold = lp_var_t(sid.objectId, PoolIds::BLOB_SIGNAL_THRESHOLD, this); - lp_var_t darkThreshold = lp_var_t(sid.objectId, PoolIds::BLOB_DARK_THRESHOLD, this); - lp_var_t enableContrast = lp_var_t(sid.objectId, PoolIds::BLOB_ENABLE_CONTRAST, this); - lp_var_t enableBinMode = lp_var_t(sid.objectId, PoolIds::BLOB_BIN_MODE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "BlobSet::printSet: mode: " << static_cast(this->mode.value) - << std::endl; - sif::info << "BlobSet::printSet: minValue: " - << static_cast(this->minValue.value) << std::endl; - sif::info << "BlobSet::printSet: minDistance: " - << static_cast(this->minDistance.value) << std::endl; - sif::info << "BlobSet::printSet: neighboutDistance: " - << static_cast(this->neighbourDistance.value) << std::endl; - sif::info << "BlobSet::printSet: neighboutBrightPixels: " - << static_cast(this->neighbourBrightPixels.value) << std::endl; - sif::info << "BlobSet::printSet: minTotalValue: " << this->minTotalValue << std::endl; - sif::info << "BlobSet::printSet: maxTotalValue: " << this->maxTotalValue << std::endl; - sif::info << "BlobSet::printSet: minBrightNeighbours: " << this->minBrightNeighbours - << std::endl; - sif::info << "BlobSet::printSet: maxBrightNeighbours: " << this->maxBrightNeighbours - << std::endl; - sif::info << "BlobSet::printSet: maxPixelsToConsider: " << this->maxPixelsToConsider - << std::endl; - sif::info << "BlobSet::printSet: signalThreshold: " - << static_cast(this->signalThreshold.value) << std::endl; - sif::info << "BlobSet::printSet: darkThreshold: " - << static_cast(this->darkThreshold.value) << std::endl; - sif::info << "BlobSet::printSet: enableContrast: " - << static_cast(this->enableContrast.value) << std::endl; - sif::info << "BlobSet::printSet: enableBinMode: " - << static_cast(this->enableBinMode.value) << std::endl; - } + void printSet() { + PoolReadGuard rg(this); + sif::info << "BlobSet::printSet: mode: " << static_cast(this->mode.value) + << std::endl; + sif::info << "BlobSet::printSet: minValue: " << static_cast(this->minValue.value) + << std::endl; + sif::info << "BlobSet::printSet: minDistance: " + << static_cast(this->minDistance.value) << std::endl; + sif::info << "BlobSet::printSet: neighboutDistance: " + << static_cast(this->neighbourDistance.value) << std::endl; + sif::info << "BlobSet::printSet: neighboutBrightPixels: " + << static_cast(this->neighbourBrightPixels.value) << std::endl; + sif::info << "BlobSet::printSet: minTotalValue: " << this->minTotalValue << std::endl; + sif::info << "BlobSet::printSet: maxTotalValue: " << this->maxTotalValue << std::endl; + sif::info << "BlobSet::printSet: minBrightNeighbours: " << this->minBrightNeighbours + << std::endl; + sif::info << "BlobSet::printSet: maxBrightNeighbours: " << this->maxBrightNeighbours + << std::endl; + sif::info << "BlobSet::printSet: maxPixelsToConsider: " << this->maxPixelsToConsider + << std::endl; + sif::info << "BlobSet::printSet: signalThreshold: " + << static_cast(this->signalThreshold.value) << std::endl; + sif::info << "BlobSet::printSet: darkThreshold: " + << static_cast(this->darkThreshold.value) << std::endl; + sif::info << "BlobSet::printSet: enableContrast: " + << static_cast(this->enableContrast.value) << std::endl; + sif::info << "BlobSet::printSet: enableBinMode: " + << static_cast(this->enableBinMode.value) << std::endl; + } }; -} +} // namespace StarTracker #endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp index 34575133..71df6b0b 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp @@ -1,669 +1,680 @@ -#include #include "StarTrackerHandler.h" -#include "OBSWConfig.h" -#include "StarTrackerJsonCommands.h" + #include #include #include + +#include + +#include "OBSWConfig.h" +#include "StarTrackerJsonCommands.h" extern "C" { - #include - #include - #include - #include "common/misc.h" +#include +#include +#include + +#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) { - if (comCookie == nullptr) { - sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; - } - if (strHelper == nullptr) { - sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; - } - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); +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; + } + if (strHelper == nullptr) { + sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; + } + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); } -StarTrackerHandler::~StarTrackerHandler() { -} +StarTrackerHandler::~StarTrackerHandler() {} ReturnValue_t StarTrackerHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } - EventManagerIF* manager = ObjectManager::instance()->get( - objects::EVENT_MANAGER); - if (manager == nullptr) { + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; + sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED;; - } - result = manager->registerListener(eventQueue->getId()); - if (result != RETURN_OK) { - return result; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), - event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); - if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + ; + } + result = manager->registerListener(eventQueue->getId()); + if (result != RETURN_OK) { + return result; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), + event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); + if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " - " str helper" << std::endl; + sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " + " str helper" + << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = strHelper->setComIF(communicationInterface); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } - strHelper->setComCookie(comCookie); - return RETURN_OK; + result = strHelper->setComIF(communicationInterface); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + strHelper->setComCookie(comCookie); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) { + const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch(actionId) { - case(StarTracker::STOP_IMAGE_LOADER): { - strHelper->stopProcess(); - return EXECUTION_FINISHED; + switch (actionId) { + case (StarTracker::STOP_IMAGE_LOADER): { + strHelper->stopProcess(); + return EXECUTION_FINISHED; } - case(StarTracker::SET_JSON_FILE_NAME): { - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - paramJsonFile = std::string(reinterpret_cast(data), size); - return EXECUTION_FINISHED; + case (StarTracker::SET_JSON_FILE_NAME): { + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + paramJsonFile = std::string(reinterpret_cast(data), size); + return EXECUTION_FINISHED; } default: - break; - } + break; + } - if (strHelperExecuting == true) { - return IMAGE_LOADER_EXECUTING; - } + if (strHelperExecuting == true) { + return IMAGE_LOADER_EXECUTING; + } - result = checkMode(actionId); - if (result != RETURN_OK) { + result = checkMode(actionId); + if (result != RETURN_OK) { + return result; + } + + // Intercept image loader commands which do not follow the common DHB communication flow + switch (actionId) { + case (StarTracker::UPLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { return result; + } + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + return FILE_PATH_TOO_LONG; + } + result = strHelper->startImageUpload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } + case (StarTracker::DOWNLOAD_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = + strHelper->startImageDownload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; + } + case (StarTracker::WRITE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeWriteCommand(data, size); + if (result != RETURN_OK) { + return result; + } - // Intercept image loader commands which do not follow the common DHB communication flow - switch(actionId) { - case(StarTracker::UPLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startImageUpload( - std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::DOWNLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startImageDownload( - std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::READ): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + result = executeReadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::WRITE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeWriteCommand(data, size); - if (result != RETURN_OK) { - return result; - } - - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::CHANGE_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::READ): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeReadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::CHANGE_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName( - std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; + case (StarTracker::SET_READ_FILENAME): { + if (size > MAX_FILE_NAME) { + return FILENAME_TOO_LONG; + } + strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); + return EXECUTION_FINISHED; } - case(StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; + case (StarTracker::DOWNLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + result = executeFpgaDownloadCommand(data, size); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } - case(StarTracker::SET_READ_FILENAME): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName( - std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; - } - case(StarTracker::DOWNLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = executeFpgaDownloadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - case(StarTracker::UPLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; + case (StarTracker::UPLOAD_FPGA_IMAGE): { + result = DeviceHandlerBase::acceptExternalDeviceCommands(); + if (result != RETURN_OK) { + return result; + } + if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + return FILE_PATH_TOO_LONG; + } + result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); + if (result != RETURN_OK) { + return result; + } + strHelperExecuting = true; + return EXECUTION_FINISHED; } default: - break; - } - return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); + break; + } + return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); } void StarTrackerHandler::performOperationHook() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; } + } } void StarTrackerHandler::doStartUp() { - switch(startupState) { + switch (startupState) { case StartupState::IDLE: - startupState = StartupState::CHECK_BOOT_STATE; - return; + startupState = StartupState::CHECK_BOOT_STATE; + return; case StartupState::BOOT_DELAY: - if (bootCountdown.hasTimedOut()) { - startupState = StartupState::LIMITS; - } - return; + if (bootCountdown.hasTimedOut()) { + startupState = StartupState::LIMITS; + } + return; case StartupState::DONE: - break; + break; default: - return; - } - setMode(_MODE_TO_ON); + return; + } + setMode(_MODE_TO_ON); } void StarTrackerHandler::doShutDown() { - // If star tracker is shutdown also stop all running processes in the image loader task - strHelper->stopProcess(); - setMode(_MODE_POWER_DOWN); + // If star tracker is shutdown also stop all running processes in the image loader task + strHelper->stopProcess(); + 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) { +ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (internalState) { case InternalState::TEMPERATURE_REQUEST: - *id = StarTracker::REQ_TEMPERATURE; - break; + *id = StarTracker::REQ_TEMPERATURE; + break; default: - sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" + << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - if (mode != _MODE_START_UP) { - return NOTHING_TO_SEND; - } - switch (startupState) { - case StartupState::CHECK_BOOT_STATE: - *id = StarTracker::REQ_VERSION; - startupState = StartupState::WAIT_FOR_EXECUTION; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::BOOT: - *id = StarTracker::BOOT; - bootCountdown.setTimeout(BOOT_TIMEOUT); - startupState = StartupState::BOOT_DELAY; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::LIMITS: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LIMITS; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::TRACKING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::TRACKING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MOUNTING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MOUNTING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CAMERA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CAMERA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::BLOB: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::BLOB; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CENTROIDING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CENTROIDING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::LISA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LISA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MATCHING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MATCHING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::VALIDATION: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::VALIDATION; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::ALGO: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::ALGO; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - default: - break; - } +ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + if (mode != _MODE_START_UP) { return NOTHING_TO_SEND; + } + switch (startupState) { + case StartupState::CHECK_BOOT_STATE: + *id = StarTracker::REQ_VERSION; + startupState = StartupState::WAIT_FOR_EXECUTION; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::BOOT: + *id = StarTracker::BOOT; + bootCountdown.setTimeout(BOOT_TIMEOUT); + startupState = StartupState::BOOT_DELAY; + return buildCommandFromCommand(*id, nullptr, 0); + case StartupState::LIMITS: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LIMITS; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::TRACKING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::TRACKING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MOUNTING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MOUNTING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CAMERA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CAMERA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::BLOB: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::BLOB; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::CENTROIDING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::CENTROIDING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::LISA: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::LISA; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::MATCHING: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::MATCHING; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::VALIDATION: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::VALIDATION; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + case StartupState::ALGO: + startupState = StartupState::WAIT_FOR_EXECUTION; + *id = StarTracker::ALGO; + return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), + paramJsonFile.size()); + default: + break; + } + return NOTHING_TO_SEND; } ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - switch (deviceCommand) { + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + switch (deviceCommand) { case (StarTracker::PING_REQUEST): { - preparePingRequest(); - return RETURN_OK; + preparePingRequest(); + return RETURN_OK; } case (StarTracker::REQ_TIME): { - prepareTimeRequest(); - return RETURN_OK; + prepareTimeRequest(); + return RETURN_OK; } case (StarTracker::BOOT): { - prepareBootCommand(); - return RETURN_OK; + prepareBootCommand(); + return RETURN_OK; } case (StarTracker::REQ_VERSION): { - prepareVersionRequest(); - return RETURN_OK; + prepareVersionRequest(); + return RETURN_OK; } case (StarTracker::REQ_INTERFACE): { - prepareInterfaceRequest(); - return RETURN_OK; + prepareInterfaceRequest(); + return RETURN_OK; } case (StarTracker::REQ_POWER): { - preparePowerRequest(); - return RETURN_OK; + preparePowerRequest(); + return RETURN_OK; } case (StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM): { - prepareRebootCommand(); - return RETURN_OK; + prepareRebootCommand(); + return RETURN_OK; } case (StarTracker::TAKE_IMAGE): { - prepareTakeImageCommand(commandData); - return RETURN_OK; + prepareTakeImageCommand(commandData); + return RETURN_OK; } case (StarTracker::SUBSCRIBE_TO_TM): { - prepareSubscriptionCommand(commandData); - return RETURN_OK; + prepareSubscriptionCommand(commandData); + return RETURN_OK; } case (StarTracker::REQ_SOLUTION): { - prepareSolutionRequest(); - return RETURN_OK; + prepareSolutionRequest(); + return RETURN_OK; } case (StarTracker::REQ_TEMPERATURE): { - prepareTemperatureRequest(); - return RETURN_OK; + prepareTemperatureRequest(); + return RETURN_OK; } case (StarTracker::REQ_HISTOGRAM): { - prepareHistogramRequest(); - return RETURN_OK; + prepareHistogramRequest(); + return RETURN_OK; } case (StarTracker::REQ_CONTRAST): { - prepareContrastRequest(); - return RETURN_OK; + prepareContrastRequest(); + return RETURN_OK; } case (StarTracker::RESET_ERROR): { - prepareErrorResetRequest(); - return RETURN_OK; + prepareErrorResetRequest(); + return RETURN_OK; } case (StarTracker::LIMITS): { - Limits limits; - result = prepareParamCommand(commandData, commandDataLen, limits); - return result; + Limits limits; + result = prepareParamCommand(commandData, commandDataLen, limits); + return result; } case (StarTracker::MOUNTING): { - Mounting mounting; - result = prepareParamCommand(commandData, commandDataLen, mounting); - return result; + Mounting mounting; + result = prepareParamCommand(commandData, commandDataLen, mounting); + return result; } case (StarTracker::CAMERA): { - Camera camera; - result = prepareParamCommand(commandData, commandDataLen, camera); - return result; + Camera camera; + result = prepareParamCommand(commandData, commandDataLen, camera); + return result; } case (StarTracker::BLOB): { - Blob blob; - result = prepareParamCommand(commandData, commandDataLen, blob); - return result; + Blob blob; + result = prepareParamCommand(commandData, commandDataLen, blob); + return result; } case (StarTracker::CENTROIDING): { - Centroiding centroiding; - result = prepareParamCommand(commandData, commandDataLen, centroiding); - return result; + Centroiding centroiding; + result = prepareParamCommand(commandData, commandDataLen, centroiding); + return result; } case (StarTracker::LISA): { - Lisa lisa; - result = prepareParamCommand(commandData, commandDataLen, lisa); - return result; + Lisa lisa; + result = prepareParamCommand(commandData, commandDataLen, lisa); + return result; } case (StarTracker::MATCHING): { - Matching matching; - result = prepareParamCommand(commandData, commandDataLen, matching); - return result; + Matching matching; + result = prepareParamCommand(commandData, commandDataLen, matching); + return result; } case (StarTracker::VALIDATION): { - Validation validation; - result = prepareParamCommand(commandData, commandDataLen, validation); - return result; + Validation validation; + result = prepareParamCommand(commandData, commandDataLen, validation); + return result; } case (StarTracker::ALGO): { - Algo algo; - result = prepareParamCommand(commandData, commandDataLen, algo); - return result; + Algo algo; + result = prepareParamCommand(commandData, commandDataLen, algo); + return result; } case (StarTracker::TRACKING): { - Tracking tracking; - result = prepareParamCommand(commandData, commandDataLen, tracking); - return result; + Tracking tracking; + result = prepareParamCommand(commandData, commandDataLen, tracking); + return result; } case (StarTracker::ERASE): { - result = prepareEraseCommand(commandData, commandDataLen); - return result; + result = prepareEraseCommand(commandData, commandDataLen); + return result; } case (StarTracker::UNLOCK): { - result = prepareUnlockCommand(commandData, commandDataLen); - return result; + result = prepareUnlockCommand(commandData, commandDataLen); + return result; } case (StarTracker::CHECKSUM): { - result = prepareChecksumCommand(commandData, commandDataLen); - return result; + result = prepareChecksumCommand(commandData, commandDataLen); + return result; } case (StarTracker::SET_TIME): { - result = prepareSetTimeCommand(commandData, commandDataLen); - return result; + result = prepareSetTimeCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_CENTROID): { - result = prepareDownloadCentroidCommand(commandData, commandDataLen); - return result; + result = prepareDownloadCentroidCommand(commandData, commandDataLen); + return result; } case (StarTracker::UPLOAD_CENTROID): { - result = prepareUploadCentroidCommand(commandData, commandDataLen); - return result; + result = prepareUploadCentroidCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); - return result; + result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_DBIMAGE): { - result = prepareDownloadDbImageCommand(commandData, commandDataLen); - return result; + result = prepareDownloadDbImageCommand(commandData, commandDataLen); + return result; } case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); - return result; + result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); + return result; } case (StarTracker::FPGA_ACTION): { - result = prepareFpgaActionCommand(commandData, commandDataLen); - return result; + result = prepareFpgaActionCommand(commandData, commandDataLen); + return result; } case (StarTracker::REQ_CAMERA): { - result = prepareRequestCameraParams(); - return result; + result = prepareRequestCameraParams(); + return result; } case (StarTracker::REQ_LIMITS): { - result = prepareRequestLimitsParams(); - return result; + result = prepareRequestLimitsParams(); + return result; } case (StarTracker::REQ_BLOB_PARAMS): { - result = prepareRequestBlobParams(); - return result; + result = prepareRequestBlobParams(); + return result; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void StarTrackerHandler::fillCommandAndReplyMap() { - /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size - * is specified */ - this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::BOOT); - this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); - this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); - this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - // Reboot has no reply. Star tracker reboots immediately - this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); - this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_CAMERA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_LIMITS, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_BLOB_PARAMS, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); + /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size + * is specified */ + this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::BOOT); + this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); + this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); + this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + // Reboot has no reply. Star tracker reboots immediately + this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); + this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_CAMERA, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_LIMITS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); + this->insertInCommandAndReplyMap(StarTracker::REQ_BLOB_PARAMS, 3, nullptr, + StarTracker::MAX_FRAME_SIZE * 2 + 2); } -ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { +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; - ReturnValue_t result = RETURN_OK; - size_t bytesLeft = 0; - - result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); - switch(result) { + result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); + switch (result) { case ArcsecDatalinkLayer::DEC_IN_PROGRESS: { - remainingSize = bytesLeft; - // Need a second doSendRead pass to reaa in whole packet - return IGNORE_REPLY_DATA; + remainingSize = bytesLeft; + // Need a second doSendRead pass to reaa in whole packet + return IGNORE_REPLY_DATA; } case RETURN_OK: { - break; + break; } default: - remainingSize = bytesLeft; - return result; - } + remainingSize = bytesLeft; + return result; + } - switch (dataLinkLayer.getReplyFrameType()) { + switch (dataLinkLayer.getReplyFrameType()) { case TMTC_ACTIONREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForActionReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForActionReply(foundId); + break; } case TMTC_SETPARAMREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForSetParameterReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForSetParameterReply(foundId); + break; } case TMTC_PARAMREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForGetParameterReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForGetParameterReply(foundId); + break; } case TMTC_TELEMETRYREPLYA: case TMTC_TELEMETRYREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForTmReply(foundId); - break; + *foundLen = remainingSize - bytesLeft; + result = scanForTmReply(foundId); + break; } default: { - sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; - result = RETURN_FAILED; - } + sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; + result = RETURN_FAILED; } + } - remainingSize = bytesLeft; + remainingSize = bytesLeft; - return result; + 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; - ReturnValue_t result = RETURN_OK; - - switch (id) { + switch (id) { case (StarTracker::SUBSCRIBE_TO_TM): { - result = handleSetParamReply(); - break; + result = handleSetParamReply(); + break; } case (StarTracker::REQ_TIME): { - result = handleTm(timeSet, StarTracker::TimeSet::SIZE); - break; + result = handleTm(timeSet, StarTracker::TimeSet::SIZE); + break; } case (StarTracker::PING_REQUEST): { - result = handlePingReply(); - break; + result = handlePingReply(); + break; } case (StarTracker::BOOT): case (StarTracker::TAKE_IMAGE): @@ -671,71 +682,71 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::UNLOCK): case (StarTracker::SET_TIME): case (StarTracker::FPGA_ACTION): { - result = handleActionReply(); - break; + result = handleActionReply(); + break; } case (StarTracker::DOWNLOAD_CENTROID): { - result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); - break; + result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); + break; } case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); - break; + result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); + break; } case (StarTracker::DOWNLOAD_DBIMAGE): { - result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); - break; + result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); + break; } case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); - break; + result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); + break; } case (StarTracker::UPLOAD_CENTROID): { - result = handleUploadCentroidReply(); - break; + result = handleUploadCentroidReply(); + break; } case (StarTracker::ERASE): { - result = handleEraseReply(); - break; + result = handleEraseReply(); + break; } case (StarTracker::CHECKSUM): { - result = handleChecksumReply(); - break; + result = handleChecksumReply(); + break; } case (StarTracker::REQ_VERSION): { - result = handleTm(versionSet, StarTracker::VersionSet::SIZE); - if (result != RETURN_OK) { - return result; - } - result = checkProgram(); - if (result != RETURN_OK) { - return result; - } - break; + result = handleTm(versionSet, StarTracker::VersionSet::SIZE); + if (result != RETURN_OK) { + return result; + } + result = checkProgram(); + if (result != RETURN_OK) { + return result; + } + break; } case (StarTracker::REQ_INTERFACE): { - result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); - break; + result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); + break; } case (StarTracker::REQ_POWER): { - result = handleTm(powerSet, StarTracker::PowerSet::SIZE); - break; + result = handleTm(powerSet, StarTracker::PowerSet::SIZE); + break; } case (StarTracker::REQ_SOLUTION): { - result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); - break; + result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); + break; } case (StarTracker::REQ_TEMPERATURE): { - result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); - break; + result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); + break; } case (StarTracker::REQ_HISTOGRAM): { - result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); - break; + result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); + break; } case (StarTracker::REQ_CONTRAST): { - result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); - break; + result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); + break; } case (StarTracker::LIMITS): case (StarTracker::MOUNTING): @@ -747,1359 +758,1348 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con case (StarTracker::TRACKING): case (StarTracker::VALIDATION): case (StarTracker::ALGO): { - result = handleSetParamReply(); - break; + result = handleSetParamReply(); + break; } case (StarTracker::REQ_CAMERA): { - handleParamRequest(cameraSet, StarTracker::CameraSet::SIZE); - break; + handleParamRequest(cameraSet, StarTracker::CameraSet::SIZE); + break; } case (StarTracker::REQ_LIMITS): { - handleParamRequest(limitsSet, StarTracker::LimitsSet::SIZE); - break; + handleParamRequest(limitsSet, StarTracker::LimitsSet::SIZE); + break; } case (StarTracker::REQ_BLOB_PARAMS): { - handleParamRequest(blobSet, StarTracker::BlobSet::SIZE); - break; + handleParamRequest(blobSet, StarTracker::BlobSet::SIZE); + break; } default: { - sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id - << std::endl; - result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id + << std::endl; + result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + 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) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::CAMERA_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::FOCALLENGTH, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::EXPOSURE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::INTERVAL, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CAMERA_OFFSET, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::PGAGAIN, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::ADCGAIN, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CAM_REG1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CAM_VAL1, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CAM_REG2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CAM_VAL2, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CAM_REG3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CAM_VAL3, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CAM_REG4, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::CAM_VAL4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAMERA_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::FOCALLENGTH, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::EXPOSURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::INTERVAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CAMERA_OFFSET, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::PGAGAIN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::ADCGAIN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CAM_REG1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CAM_VAL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CAM_REG2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CAM_VAL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CAM_REG3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CAM_VAL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CAM_REG4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::CAM_VAL4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(StarTracker::LIMITS_ACTION, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LIMITS_FPGA18CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LIMITS_FPGA25CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LIMITS_FPGA10CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LIMITS_MCUCURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOS21CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOSPIXCURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOS33CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOSVRESCURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::LIMITS_CMOSTEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_ACTION, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LIMITS_FPGA18CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LIMITS_FPGA25CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LIMITS_FPGA10CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LIMITS_MCUCURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOS21CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOSPIXCURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOS33CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOSVRESCURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOSTEMPERATURE, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(StarTracker::BLOB_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_MIN_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_MIN_DISTANCE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_DISTANCE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_MIN_TOTAL_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_MAX_TOTAL_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_MIN_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_MAX_BRIGHT_NEIGHBOURS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_MAX_PIXELSTOCONSIDER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_SIGNAL_THRESHOLD, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_DARK_THRESHOLD, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_HISTOGRAM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_CONTRAST, new PoolEntry( { 0 })); - localDataPoolMap.emplace(StarTracker::BLOB_BIN_MODE, new PoolEntry( { 0 })); - return RETURN_OK; + localDataPoolMap.emplace(StarTracker::BLOB_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_DISTANCE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_DISTANCE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_TOTAL_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_MAX_TOTAL_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_MIN_BRIGHT_NEIGHBOURS, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_MAX_BRIGHT_NEIGHBOURS, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_MAX_PIXELSTOCONSIDER, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_SIGNAL_THRESHOLD, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_DARK_THRESHOLD, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_HISTOGRAM, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_CONTRAST, new PoolEntry({0})); + localDataPoolMap.emplace(StarTracker::BLOB_BIN_MODE, new PoolEntry({0})); + return RETURN_OK; } -size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){ - return StarTracker::MAX_FRAME_SIZE; +size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId) { + return StarTracker::MAX_FRAME_SIZE; } ReturnValue_t StarTrackerHandler::doSendReadHook() { - // Prevent DHB from polling UART during commands executed by the image loader task - if(strHelperExecuting) { - return RETURN_FAILED; - } - return RETURN_OK; + // Prevent DHB from polling UART during commands executed by the image loader task + if (strHelperExecuting) { + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) { - switch(actionId) { + switch (actionId) { case StarTracker::UPLOAD_IMAGE: case StarTracker::DOWNLOAD_IMAGE: { - return DeviceHandlerBase::acceptExternalDeviceCommands(); - default: + return DeviceHandlerBase::acceptExternalDeviceCommands(); + default: break; } - } - return RETURN_OK; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { +ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::PING): { - *foundId = StarTracker::PING_REQUEST; - break; + *foundId = StarTracker::PING_REQUEST; + break; } case (StarTracker::ID::WRITE): { - *foundId = StarTracker::WRITE; - break; + *foundId = StarTracker::WRITE; + break; } case (StarTracker::ID::BOOT): { - *foundId = StarTracker::BOOT; - break; + *foundId = StarTracker::BOOT; + break; } case (StarTracker::ID::TAKE_IMAGE): { - *foundId = StarTracker::TAKE_IMAGE; - break; + *foundId = StarTracker::TAKE_IMAGE; + break; } case (StarTracker::ID::UPLOAD_IMAGE): { - *foundId = StarTracker::UPLOAD_IMAGE; - break; + *foundId = StarTracker::UPLOAD_IMAGE; + break; } case (StarTracker::ID::ERROR_RESET): { - *foundId = StarTracker::RESET_ERROR; - break; + *foundId = StarTracker::RESET_ERROR; + break; } case (StarTracker::ID::ERASE): { - *foundId = StarTracker::ERASE; - break; + *foundId = StarTracker::ERASE; + break; } case (StarTracker::ID::UNLOCK): { - *foundId = StarTracker::UNLOCK; - break; + *foundId = StarTracker::UNLOCK; + break; } case (StarTracker::ID::CHECKSUM): { - *foundId = StarTracker::CHECKSUM; - break; + *foundId = StarTracker::CHECKSUM; + break; } case (StarTracker::ID::SET_TIME): { - *foundId = StarTracker::SET_TIME; - break; + *foundId = StarTracker::SET_TIME; + break; } case (StarTracker::ID::DOWNLOAD_CENTROID): { - *foundId = StarTracker::DOWNLOAD_CENTROID; - break; + *foundId = StarTracker::DOWNLOAD_CENTROID; + break; } case (StarTracker::ID::UPLOAD_CENTROID): { - *foundId = StarTracker::UPLOAD_CENTROID; - break; + *foundId = StarTracker::UPLOAD_CENTROID; + break; } case (StarTracker::ID::DOWNLOAD_MATCHED_STAR): { - *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; - break; + *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; + break; } case (StarTracker::ID::DOWNLOAD_DBIMAGE): { - *foundId = StarTracker::DOWNLOAD_DBIMAGE; - break; + *foundId = StarTracker::DOWNLOAD_DBIMAGE; + break; } case (StarTracker::ID::DOWNLOAD_BLOBPIXEL): { - *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; - break; + *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; + break; } case (StarTracker::ID::FPGA_ACTION): { - *foundId = StarTracker::FPGA_ACTION; - break; + *foundId = StarTracker::FPGA_ACTION; + break; } default: - sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { +ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { case (StarTracker::ID::SUBSCRIBE): { - *foundId = StarTracker::SUBSCRIBE_TO_TM; - break; + *foundId = StarTracker::SUBSCRIBE_TO_TM; + break; } case (StarTracker::ID::LIMITS): { - *foundId = StarTracker::LIMITS; - break; + *foundId = StarTracker::LIMITS; + break; } case (StarTracker::ID::MOUNTING): { - *foundId = StarTracker::MOUNTING; - break; + *foundId = StarTracker::MOUNTING; + break; } case (StarTracker::ID::CAMERA): { - *foundId = StarTracker::CAMERA; - break; + *foundId = StarTracker::CAMERA; + break; } case (StarTracker::ID::BLOB): { - *foundId = StarTracker::BLOB; - break; + *foundId = StarTracker::BLOB; + break; } case (StarTracker::ID::CENTROIDING): { - *foundId = StarTracker::CENTROIDING; - break; + *foundId = StarTracker::CENTROIDING; + break; } case (StarTracker::ID::LISA): { - *foundId = StarTracker::LISA; - break; + *foundId = StarTracker::LISA; + break; } case (StarTracker::ID::MATCHING): { - *foundId = StarTracker::MATCHING; - break; + *foundId = StarTracker::MATCHING; + break; } case (StarTracker::ID::TRACKING): { - *foundId = StarTracker::TRACKING; - break; + *foundId = StarTracker::TRACKING; + break; } case (StarTracker::ID::VALIDATION): { - *foundId = StarTracker::VALIDATION; - break; + *foundId = StarTracker::VALIDATION; + break; } case (StarTracker::ID::ALGO): { - *foundId = StarTracker::ALGO; - break; + *foundId = StarTracker::ALGO; + break; } default: - sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" + << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForGetParameterReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { - case (StarTracker::ID::CAMERA): { - *foundId = StarTracker::REQ_CAMERA; - break; - } - case (StarTracker::ID::LIMITS): { - *foundId = StarTracker::REQ_LIMITS; - break; - } - case (StarTracker::ID::BLOB): { - *foundId = StarTracker::REQ_BLOB_PARAMS; - break; - } - default: { - sif::warning << "tarTrackerHandler::scanForGetParameterReply: UnkNown ID" << std::endl; - return RETURN_FAILED; - break; - } +ReturnValue_t StarTrackerHandler::scanForGetParameterReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { + case (StarTracker::ID::CAMERA): { + *foundId = StarTracker::REQ_CAMERA; + break; } - return RETURN_OK; + case (StarTracker::ID::LIMITS): { + *foundId = StarTracker::REQ_LIMITS; + break; + } + case (StarTracker::ID::BLOB): { + *foundId = StarTracker::REQ_BLOB_PARAMS; + break; + } + default: { + sif::warning << "tarTrackerHandler::scanForGetParameterReply: UnkNown ID" << std::endl; + return RETURN_FAILED; + break; + } + } + return RETURN_OK; } -ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t *foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { - case (StarTracker::ID::VERSION): { - *foundId = StarTracker::REQ_VERSION; - break; - } - case (StarTracker::ID::INTERFACE): { - *foundId = StarTracker::REQ_INTERFACE; - break; - } - case (StarTracker::ID::POWER): { - *foundId = StarTracker::REQ_POWER; - break; - } - case (StarTracker::ID::TEMPERATURE): { - *foundId = StarTracker::REQ_TEMPERATURE; - break; - } - case (StarTracker::ID::HISTOGRAM): { - *foundId = StarTracker::REQ_HISTOGRAM; - break; - } - case (StarTracker::ID::CONTRAST): { - *foundId = StarTracker::REQ_CONTRAST; - break; - } - case (StarTracker::ID::TIME): { - *foundId = StarTracker::REQ_TIME; - break; - } - case (StarTracker::ID::SOLUTION): { - *foundId = StarTracker::REQ_SOLUTION; - break; - } - default: { - sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" - << std::endl; - return RETURN_FAILED; - break; - } +ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t* foundId) { + const uint8_t* reply = dataLinkLayer.getReply(); + switch (*reply) { + case (StarTracker::ID::VERSION): { + *foundId = StarTracker::REQ_VERSION; + break; } - return RETURN_OK; + case (StarTracker::ID::INTERFACE): { + *foundId = StarTracker::REQ_INTERFACE; + break; + } + case (StarTracker::ID::POWER): { + *foundId = StarTracker::REQ_POWER; + break; + } + case (StarTracker::ID::TEMPERATURE): { + *foundId = StarTracker::REQ_TEMPERATURE; + break; + } + case (StarTracker::ID::HISTOGRAM): { + *foundId = StarTracker::REQ_HISTOGRAM; + break; + } + case (StarTracker::ID::CONTRAST): { + *foundId = StarTracker::REQ_CONTRAST; + break; + } + case (StarTracker::ID::TIME): { + *foundId = StarTracker::REQ_TIME; + break; + } + case (StarTracker::ID::SOLUTION): { + *foundId = StarTracker::REQ_SOLUTION; + break; + } + default: { + sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" + << std::endl; + return RETURN_FAILED; + break; + } + } + return RETURN_OK; } void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { - object_id_t objectId = eventMessage->getReporter(); - switch(objectId){ + object_id_t objectId = eventMessage->getReporter(); + switch (objectId) { case objects::STR_HELPER: { - // All events from image loader signal either that the operation was successful or that it - // failed - strHelperExecuting = false; - break; + // All events from image loader signal either that the operation was successful or that it + // failed + strHelperExecuting = false; + break; } default: - sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" - << std::endl; - break; - } + sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" << std::endl; + break; + } } ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < WriteCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(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); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; - std::string fullname = std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region)); - result = strHelper->startFlashWrite(fullname, region, address); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < WriteCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(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); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" + << std::endl; return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; + std::string fullname = std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region)); + result = strHelper->startFlashWrite(fullname, region, address); + if (result != RETURN_OK) { + return result; + } + return result; } ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" - << std::endl; - return COMMAND_TOO_SHORT; - } - uint32_t position; - size_t size = sizeof(position); - result = SerializeAdapter::deSerialize(&position, &commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " - " invalid path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - std::string fullname = std::string(reinterpret_cast(commandData), - commandDataLen - sizeof(position) - sizeof(length)); - result = strHelper->startFpgaDownload(fullname, position, length); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" + << std::endl; + return COMMAND_TOO_SHORT; + } + uint32_t position; + size_t size = sizeof(position); + result = + SerializeAdapter::deSerialize(&position, &commandData, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" + << std::endl; return result; + } + uint32_t length; + size = sizeof(length); + result = + SerializeAdapter::deSerialize(&length, &commandData, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " + " invalid path and filename" + << std::endl; + return FILE_PATH_TOO_LONG; + } + std::string fullname = std::string(reinterpret_cast(commandData), + commandDataLen - sizeof(position) - sizeof(length)); + result = strHelper->startFpgaDownload(fullname, position, length); + if (result != RETURN_OK) { + return result; + } + return result; } ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < ReadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(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); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; - std::string fullname = std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); - result = strHelper->startFlashRead(fullname, region, address, length); - if (result != RETURN_OK) { - return result; - } + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen < ReadCmd::MIN_LENGTH) { + sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; + return COMMAND_TOO_SHORT; + } + uint8_t region = *(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); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" + << std::endl; return result; + } + uint32_t length; + size = sizeof(length); + const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; + result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" + << std::endl; + return result; + } + if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { + sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" + << " path and filename" << std::endl; + return FILE_PATH_TOO_LONG; + } + const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; + std::string fullname = + std::string(reinterpret_cast(filePtr), + commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); + result = strHelper->startFlashRead(fullname, region, address, length); + if (result != RETURN_OK) { + return result; + } + return result; } void StarTrackerHandler::prepareBootCommand() { - uint32_t length = 0; - struct BootActionRequest bootRequest = {BOOT_REGION_ID}; - arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct BootActionRequest bootRequest = {BOOT_REGION_ID}; + arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::prepareEraseCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen != EraseCmd::LENGTH) { - return INVALID_LENGTH; - } - uint32_t length = 0; - struct EraseActionRequest req; - req.region = *commandData; - arc_pack_erase_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - eraseCmd.rememberRegion = req.region; - return result; + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen != EraseCmd::LENGTH) { + return INVALID_LENGTH; + } + uint32_t length = 0; + struct EraseActionRequest req; + req.region = *commandData; + arc_pack_erase_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + eraseCmd.rememberRegion = req.region; + return result; } ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - uint32_t length = 0; - struct UnlockActionRequest req; - 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); - if (result != RETURN_OK) { - return result; - } - arc_pack_unlock_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + uint32_t length = 0; + struct UnlockActionRequest req; + 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); + if (result != RETURN_OK) { return result; + } + arc_pack_unlock_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData, - size_t commandDataLen) { - struct ChecksumActionRequest req; - ReturnValue_t result = RETURN_OK; - if (commandDataLen != ChecksumCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - 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); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " - << "failed" << std::endl; - return result; - } - size = sizeof(req.length); - const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" - << std::endl; - return result; - } - uint32_t rawCmdLength = 0; - arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); - dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - checksumCmd.rememberRegion = req.region; - checksumCmd.rememberAddress = req.address; - checksumCmd.rememberLength = req.length; + size_t commandDataLen) { + struct ChecksumActionRequest req; + ReturnValue_t result = RETURN_OK; + if (commandDataLen != ChecksumCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + 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); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " + << "failed" << std::endl; return result; + } + size = sizeof(req.length); + const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; + result = + SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" + << std::endl; + return result; + } + uint32_t rawCmdLength = 0; + arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); + dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + checksumCmd.rememberRegion = req.region; + checksumCmd.rememberAddress = req.address; + checksumCmd.rememberLength = req.length; + return result; } - ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct SetTimeActionRequest req; - if (commandDataLen != SetTimeCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - size_t size = sizeof(req.unixTime); - result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" - << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_settime_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct SetTimeActionRequest req; + if (commandDataLen != SetTimeCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; + return INVALID_LENGTH; + } + size_t size = sizeof(req.unixTime); + result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" << std::endl; return result; + } + uint32_t length = 0; + arc_pack_settime_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareDownloadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct DownloadCentroidActionRequest req; - if (commandDataLen != DownloadCentroidCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" - << std::endl; - return INVALID_LENGTH; - } - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + struct DownloadCentroidActionRequest req; + if (commandDataLen != DownloadCentroidCmd::LENGTH) { + sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" + << std::endl; + return INVALID_LENGTH; + } + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return result; } ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - ReturnValue_t result = RETURN_OK; - struct UploadCentroidActionRequest req; - std::string jsonFileName = std::string(reinterpret_cast(commandData), - commandDataLen); - NVMParameterBase j(jsonFileName); - result = j.readJsonFile(); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName - << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; - return result; - } - 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; - 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; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - uploadCentroid.rememberId = req.id; + size_t commandDataLen) { + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + ReturnValue_t result = RETURN_OK; + struct UploadCentroidActionRequest req; + std::string jsonFileName = + std::string(reinterpret_cast(commandData), commandDataLen); + NVMParameterBase j(jsonFileName); + result = j.readJsonFile(); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName + << " does not exist" << std::endl; return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; + return result; + } + 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; + 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; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; + return result; + } + result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " + << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; + return result; + } + uint32_t length = 0; + arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + uploadCentroid.rememberId = req.id; + return result; } void StarTrackerHandler::prepareTimeRequest() { - uint32_t length = 0; - arc_tm_pack_time_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_time_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePingRequest() { - uint32_t length = 0; - struct PingActionRequest pingRequest = {PING_ID}; - arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct PingActionRequest pingRequest = {PING_ID}; + arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareVersionRequest() { - uint32_t length = 0; - arc_tm_pack_version_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_version_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareInterfaceRequest() { - uint32_t length = 0; - arc_tm_pack_interface_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_interface_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::preparePowerRequest() { - uint32_t length = 0; - arc_tm_pack_power_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_power_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareRebootCommand() { - uint32_t length = 0; - struct RebootActionRequest rebootReq; - arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct RebootActionRequest rebootReq; + arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTakeImageCommand(const uint8_t* commandData) { - uint32_t length = 0; - struct CameraActionRequest camReq; - camReq.actionid = *commandData; - arc_pack_camera_action_req(&camReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct CameraActionRequest camReq; + camReq.actionid = *commandData; + arc_pack_camera_action_req(&camReq, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { - uint32_t length = 18; - commandBuffer[0] = TMTC_SETPARAMREQ; - commandBuffer[1] = StarTracker::ID::SUBSCRIBE; - // Fill all other fields with invalid tm id - commandBuffer[2] = *tmId; - commandBuffer[3] = 0; - commandBuffer[4] = 0; - commandBuffer[5] = 0; - commandBuffer[6] = 0; - commandBuffer[7] = 0; - commandBuffer[8] = 0; - commandBuffer[9] = 0; - commandBuffer[10] = 0; - commandBuffer[11] = 0; - commandBuffer[12] = 0; - commandBuffer[13] = 0; - commandBuffer[14] = 0; - commandBuffer[15] = 0; - commandBuffer[16] = 0; - commandBuffer[17] = 0; - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 18; + commandBuffer[0] = TMTC_SETPARAMREQ; + commandBuffer[1] = StarTracker::ID::SUBSCRIBE; + // Fill all other fields with invalid tm id + commandBuffer[2] = *tmId; + commandBuffer[3] = 0; + commandBuffer[4] = 0; + commandBuffer[5] = 0; + commandBuffer[6] = 0; + commandBuffer[7] = 0; + commandBuffer[8] = 0; + commandBuffer[9] = 0; + commandBuffer[10] = 0; + commandBuffer[11] = 0; + commandBuffer[12] = 0; + commandBuffer[13] = 0; + commandBuffer[14] = 0; + commandBuffer[15] = 0; + commandBuffer[16] = 0; + commandBuffer[17] = 0; + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareSolutionRequest() { - uint32_t length = 0; - arc_tm_pack_solution_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_solution_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareTemperatureRequest() { - uint32_t length = 0; - arc_tm_pack_temperature_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_temperature_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareHistogramRequest() { - uint32_t length = 0; - arc_tm_pack_histogram_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_histogram_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareContrastRequest() { - uint32_t length = 0; - arc_tm_pack_contrast_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + arc_tm_pack_contrast_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } void StarTrackerHandler::prepareErrorResetRequest() { - uint32_t length = 0; - struct ResetErrorSignalActionRequest req; - arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); + uint32_t length = 0; + struct ResetErrorSignalActionRequest req; + arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); } ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, - size_t commandDataLen, ArcsecJsonParamBase& paramSet) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - std::string fullName(reinterpret_cast(commandData), commandDataLen); + size_t commandDataLen, + ArcsecJsonParamBase& paramSet) { + ReturnValue_t result = RETURN_OK; + if (commandDataLen > MAX_PATH_SIZE) { + return FILE_PATH_TOO_LONG; + } + std::string fullName(reinterpret_cast(commandData), commandDataLen); - result = paramSet.create(fullName, commandBuffer); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " - "command" << std::endl; - return result; - } - dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + result = paramSet.create(fullName, commandBuffer); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " + "command" + << std::endl; + return result; + } + dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadMatchedStarActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadMatchedStarActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadDbImageCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadDbImageCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadDBImageActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadDbImageCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadDBImageActionRequest req; + req.id = *commandData; + uint32_t length = 0; + arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareDownloadBlobPixelCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadBlobPixCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadBlobPixelActionRequest req; - req.id = *commandData; - req.type = *(commandData + 1); - if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { - return INVALID_TYPE; - } - uint32_t length = 0; - arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != DownloadBlobPixCmd::LENGTH) { + return INVALID_LENGTH; + } + struct DownloadBlobPixelActionRequest req; + req.id = *commandData; + req.type = *(commandData + 1); + if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { + return INVALID_TYPE; + } + uint32_t length = 0; + arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != FpgaActionCmd::LENGTH) { - return INVALID_LENGTH; - } - struct FPGAActionActionRequest req; - req.id = *commandData; - if (req.id != FpgaActionCmd::ID) { - return INVALID_ID; - } - uint32_t length = 0; - arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + size_t commandDataLen) { + if (commandDataLen != FpgaActionCmd::LENGTH) { + return INVALID_LENGTH; + } + struct FPGAActionActionRequest req; + req.id = *commandData; + if (req.id != FpgaActionCmd::ID) { + return INVALID_ID; + } + uint32_t length = 0; + arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareRequestCameraParams() { - uint32_t length = 0; - arc_pack_camera_parameter_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + uint32_t length = 0; + arc_pack_camera_parameter_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareRequestLimitsParams() { - uint32_t length = 0; - arc_pack_limits_parameter_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + uint32_t length = 0; + arc_pack_limits_parameter_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::prepareRequestBlobParams() { - uint32_t length = 0; - arc_pack_blob_parameter_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; + uint32_t length = 0; + arc_pack_blob_parameter_req(commandBuffer, &length); + dataLinkLayer.encodeFrame(commandBuffer, length); + rawPacket = dataLinkLayer.getEncodedFrame(); + rawPacketLen = dataLinkLayer.getEncodedLength(); + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleSetParamReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - 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(*(reply + PARAMETER_ID_OFFSET)) << std::endl; - if (startupState != StartupState::IDLE) { - startupState = StartupState::IDLE; - } - return SET_PARAM_FAILED; - } + const uint8_t* reply = dataLinkLayer.getReply(); + 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(*(reply + PARAMETER_ID_OFFSET)) << std::endl; if (startupState != StartupState::IDLE) { - handleStartup(reply + PARAMETER_ID_OFFSET); + startupState = StartupState::IDLE; } - return RETURN_OK; + return SET_PARAM_FAILED; + } + if (startupState != StartupState::IDLE) { + handleStartup(reply + PARAMETER_ID_OFFSET); + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleActionReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " - << "command with action ID " - << static_cast(*(reply + ACTION_ID_OFFSET)) - << " and status "<< static_cast(status) << std::endl; - return ACTION_FAILED; - } - return RETURN_OK; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = *(reply + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " + << "command with action ID " + << static_cast(*(reply + ACTION_ID_OFFSET)) << " and status " + << static_cast(status) << std::endl; + return ACTION_FAILED; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleUploadCentroidReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { - return UPLOAD_CENTROID_ID_MISMATCH; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* reply = dataLinkLayer.getReply(); + if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { + return UPLOAD_CENTROID_ID_MISMATCH; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleEraseReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::EraseReply eraseReply(replyData); - if (eraseReply.getRegion() != eraseCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::EraseReply eraseReply(replyData); + if (eraseReply.getRegion() != eraseCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + return result; } ReturnValue_t StarTrackerHandler::handleChecksumReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::ChecksumReply checksumReply(replyData); - if (checksumReply.getRegion() != checksumCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } - if (checksumReply.getAddress() != checksumCmd.rememberAddress) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; - return ADDRESS_MISMATCH; - } - if (checksumReply.getLength() != checksumCmd.rememberLength) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; - return LENGTH_MISSMATCH; - } - PoolReadGuard rg(&checksumSet); - checksumSet.checksum = checksumReply.getChecksum(); - handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); + ReturnValue_t result = RETURN_OK; + result = handleActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + StarTracker::ChecksumReply checksumReply(replyData); + if (checksumReply.getRegion() != checksumCmd.rememberRegion) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; + return REGION_MISMATCH; + } + if (checksumReply.getAddress() != checksumCmd.rememberAddress) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; + return ADDRESS_MISMATCH; + } + if (checksumReply.getLength() != checksumCmd.rememberLength) { + sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; + return LENGTH_MISSMATCH; + } + PoolReadGuard rg(&checksumSet); + checksumSet.checksum = checksumReply.getChecksum(); + handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - checksumReply.printChecksum(); + checksumReply.printChecksum(); #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - return RETURN_OK; + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleParamRequest(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + PARAMS_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleParamRequest Deserialization failed" - << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif + ReturnValue_t result = RETURN_OK; + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + PARAMS_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleParamRequest Deserialization failed" << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; } ReturnValue_t StarTrackerHandler::handlePingReply() { - ReturnValue_t result = RETURN_OK; - uint32_t pingId = 0; - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = dataLinkLayer.getStatusField(); - const uint8_t* buffer = reply + ACTION_DATA_OFFSET; - size_t size = sizeof(pingId); - SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); + ReturnValue_t result = RETURN_OK; + uint32_t pingId = 0; + const uint8_t* reply = dataLinkLayer.getReply(); + uint8_t status = dataLinkLayer.getStatusField(); + const uint8_t* buffer = reply + ACTION_DATA_OFFSET; + size_t size = sizeof(pingId); + SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping status: "<< static_cast(status) << std::endl; - sif::info << "Ping id: 0x"<< std::hex << pingId << std::endl; + sif::info << "StarTracker: Ping status: " << static_cast(status) << std::endl; + sif::info << "Ping id: 0x" << std::hex << pingId << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - if (status != StarTracker::STATUS_OK || pingId != PING_ID) { - sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; - result = PING_FAILED; - } - else { + if (status != StarTracker::STATUS_OK || pingId != PING_ID) { + sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; + result = PING_FAILED; + } else { #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping successful" << std::endl; + sif::info << "StarTracker: Ping successful" << std::endl; #endif - } - return result; + } + return result; } ReturnValue_t StarTrackerHandler::checkProgram() { - PoolReadGuard pg(&versionSet); - switch(versionSet.program.value) { + PoolReadGuard pg(&versionSet); + switch (versionSet.program.value) { case StarTracker::Program::BOOTLOADER: - // Star tracker currently in bootloader program. Need to send boot command to switch to - // firmware program - if (startupState != StartupState::IDLE) { - startupState = StartupState::BOOT; - } - break; + // Star tracker currently in bootloader program. Need to send boot command to switch to + // firmware program + if (startupState != StartupState::IDLE) { + startupState = StartupState::BOOT; + } + break; case StarTracker::Program::FIRMWARE: - // Firmware already booted - if (startupState != StartupState::IDLE) { - startupState = StartupState::LIMITS; - } - break; + // Firmware already booted + if (startupState != StartupState::IDLE) { + startupState = StartupState::LIMITS; + } + break; default: - sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" - << std::endl; - return INVALID_PROGRAM; - } - return RETURN_OK; + sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" + << std::endl; + return INVALID_PROGRAM; + } + return RETURN_OK; } ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleTm: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" - << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif + ReturnValue_t result = RETURN_OK; + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleTm: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; } ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if(status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" - << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif + ReturnValue_t result = RETURN_OK; + uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); + if (status != StarTracker::STATUS_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " + << static_cast(status) << std::endl; + return REPLY_ERROR; + } + result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { return result; + } + const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; + dataset.setValidityBufferGeneration(false); + result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" << std::endl; + } + dataset.setValidityBufferGeneration(true); + dataset.setValidity(true, true); + result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); + if (result != RETURN_OK) { + return result; + } +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 + dataset.printSet(); +#endif + return result; } void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { - switch(*parameterId) { + switch (*parameterId) { case (StarTracker::ID::LIMITS): { - startupState = StartupState::TRACKING; - break; + startupState = StartupState::TRACKING; + break; } case (StarTracker::ID::TRACKING): { - startupState = StartupState::MOUNTING; - break; + startupState = StartupState::MOUNTING; + break; } case (StarTracker::ID::MOUNTING): { - startupState = StartupState::CAMERA; - break; + startupState = StartupState::CAMERA; + break; } case (StarTracker::ID::CAMERA): { - startupState = StartupState::BLOB; - break; + startupState = StartupState::BLOB; + break; } case (StarTracker::ID::BLOB): { - startupState = StartupState::CENTROIDING; - break; + startupState = StartupState::CENTROIDING; + break; } case (StarTracker::ID::CENTROIDING): { - startupState = StartupState::LISA; - break; + startupState = StartupState::LISA; + break; } case (StarTracker::ID::LISA): { - startupState = StartupState::MATCHING; - break; + startupState = StartupState::MATCHING; + break; } case (StarTracker::ID::MATCHING): { - startupState = StartupState::VALIDATION; - break; + startupState = StartupState::VALIDATION; + break; } case (StarTracker::ID::VALIDATION): { - startupState = StartupState::ALGO; - break; + startupState = StartupState::ALGO; + break; } case (StarTracker::ID::ALGO): { - startupState = StartupState::DONE; - break; + startupState = StartupState::DONE; + break; } default: { - sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" - << " parameter ID" << std::endl; - break; - } + sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" + << " parameter ID" << std::endl; + break; } + } } diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.h b/bsp_q7s/devices/startracker/StarTrackerHandler.h index 2a7c7501..70be3099 100644 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.h +++ b/bsp_q7s/devices/startracker/StarTrackerHandler.h @@ -1,15 +1,16 @@ #ifndef MISSION_DEVICES_STARTRACKERHANDLER_H_ #define MISSION_DEVICES_STARTRACKERHANDLER_H_ +#include + +#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 -#include "ArcsecDatalinkLayer.h" -#include "StarTrackerDefinitions.h" -#include "ArcsecJsonParamBase.h" -#include "StrHelper.h" /** * @brief This is the device handler for the star tracker from arcsec. @@ -19,552 +20,546 @@ * Sagitta%201.0%20Datapack&fileid=659181 * @author J. Meier */ -class StarTrackerHandler: public DeviceHandlerBase { -public: - - /** - * @brief Constructor - * - * @param objectId - * @param comIF - * @param comCookie - * @param gpioComIF Pointer to gpio communication interface - * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled - * to high to enable the device. - */ - StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - StrHelper* strHelper); - virtual ~StarTrackerHandler(); - - ReturnValue_t initialize() override; - - /** - * @brief Overwrite this function from DHB to handle commands executed by the str image - * loader task. - */ - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - - void performOperationHook() override; - -protected: - void doStartUp() override; - void doShutDown() override; - void doOffActivity() override; - 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; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - /** - * @brief Overwritten here to always read all available data from the UartComIF. - */ - virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; - virtual ReturnValue_t doSendReadHook() override; - -private: - - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; - - //! [EXPORT] : [COMMENT] Received reply is too short - static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Received reply with invalid CRC - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Image loader executing - static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); - - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; - - //! [EXPORT] : [COMMENT] Status in temperature reply signals error - static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Ping command failed - static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Status in version reply signals error - static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Status in interface reply signals error - static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); - //! [EXPORT] : [COMMENT] Status in power reply signals error - static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error - static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Status of reply to action command signals error - static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Received upload image command with invalid position field - static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position - static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); - //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length - static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); - //! [EXPORT] : [COMMENT] Name of file received with command is too long - static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); - //! [EXPORT] : [COMMENT] Received version reply with invalid program ID - static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); - //! [EXPORT] : [COMMENT] Status field reply signals error - 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) - 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); - //! [EXPORT] : [COMMENT] Region mismatch between send and received data - static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Address mismatch between send and received data - static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); - //! [EXPORT] : [COMMENT] Length field mismatch between send and received data - static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); - //! [EXPORT] : [COMMENT] Specified file does not exist - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id - static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); - //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field - static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); - //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID - static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); - - static const size_t MAX_PATH_SIZE = 50; - static const size_t MAX_FILE_NAME = 30; - - // position (uint32) + 1024 image data - static const size_t UPLOAD_COMMAND_LEN = 1028; - // Max valid position value in upload image command - static const uint16_t MAX_POSITION= 4095; - static const uint8_t STATUS_OFFSET = 1; - static const uint8_t PARAMS_OFFSET = 1; - static const uint8_t TICKS_OFFSET = 2; - static const uint8_t TIME_OFFSET = 6; - static const uint8_t TM_DATA_FIELD_OFFSET = 14; - static const uint8_t PARAMETER_ID_OFFSET = 0; - static const uint8_t ACTION_ID_OFFSET = 0; - static const uint8_t ACTION_DATA_OFFSET = 2; - // Ping request will reply ping with this ID (data field) - static const uint32_t PING_ID = 0x55; - static const uint32_t BOOT_REGION_ID = 1; - static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; - static const uint32_t MUTEX_TIMEOUT = 20; - static const uint32_t BOOT_TIMEOUT = 1000; - - class WriteCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t FILE_OFFSET = 5; - // Minimum length of a write command (region, address and filename) - static const size_t MIN_LENGTH = 7; - }; - - class ReadCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - static const uint8_t FILE_OFFSET = 9; - // Minimum length of a read command (region, address, length and filename) - static const size_t MIN_LENGTH = 11; - }; - - class EraseCmd { - public: - static const uint8_t LENGTH = 1; - uint8_t rememberRegion = 0; - }; - - EraseCmd eraseCmd; - - class UnlockCmd { - public: - static const uint8_t CODE_OFFSET = 1; - }; - - class ChecksumCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t LENGTH_OFFSET = 5; - // Length of checksum command - static const size_t LENGTH = 9; - uint8_t rememberRegion = 0; - uint32_t rememberAddress = 0; - uint32_t rememberLength = 0; - }; - - ChecksumCmd checksumCmd; - - class SetTimeCmd { - public: - static const uint8_t LENGTH = 8; - }; - - class DownloadCentroidCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class UploadCentroid { - public: - uint8_t rememberId = 0; - }; - - UploadCentroid uploadCentroid; - - class DownloadMatchedStarCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadDbImageCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadBlobPixCmd { - public: - static const uint8_t LENGTH = 2; - static const uint8_t NORMAL = 0; - static const uint8_t FAST = 1; - }; - - class FpgaDownloadCmd { - public: - static const uint8_t MIN_LENGTH = 10; - }; - - class FpgaActionCmd { - public: - static const uint8_t LENGTH = 1; - static const uint8_t ID = 3; - }; - - MessageQueueIF* eventQueue = nullptr; - - ArcsecDatalinkLayer dataLinkLayer; - - StarTracker::TemperatureSet temperatureSet; - StarTracker::VersionSet versionSet; - StarTracker::PowerSet powerSet; - StarTracker::InterfaceSet interfaceSet; - StarTracker::TimeSet timeSet; - StarTracker::SolutionSet solutionSet; - StarTracker::HistogramSet histogramSet; - StarTracker::ContrastSet contrastSet; - StarTracker::ChecksumSet checksumSet; - StarTracker::DownloadCentroidSet downloadCentroidSet; - StarTracker::DownloadMatchedStar downloadMatchedStar; - StarTracker::DownloadDBImage downloadDbImage; - StarTracker::DownloadBlobPixel downloadBlobPixel; - StarTracker::CameraSet cameraSet; - StarTracker::LimitsSet limitsSet; - StarTracker::BlobSet blobSet; - - // Pointer to object responsible for uploading and downloading images to/from the star tracker - StrHelper* strHelper = nullptr; - - uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - - // Countdown to insert delay for star tracker to switch from bootloader to firmware program - Countdown bootCountdown; - - std::string paramJsonFile = "/mnt/sd0/startracker/full.json"; - - enum class InternalState { - TEMPERATURE_REQUEST - }; - - InternalState internalState = InternalState::TEMPERATURE_REQUEST; - - enum class StartupState { - IDLE, - CHECK_BOOT_STATE, - BOOT, - BOOT_DELAY, - LIMITS, - TRACKING, - MOUNTING, - CAMERA, - BLOB, - CENTROIDING, - LISA, - MATCHING, - VALIDATION, - ALGO, - WAIT_FOR_EXECUTION, - DONE - }; - - StartupState startupState = StartupState::IDLE; - - bool strHelperExecuting = false; - - /** - * @brief Handles internal state - */ - void handleInternalState(); - - /** - * @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution. - * - * @param actionId Action id of command to execute - */ - ReturnValue_t checkMode(ActionId_t actionId); - - /** - * @brief This function initializes the serial link ip protocol struct slipInfo. - */ - void slipInit(); - - ReturnValue_t scanForActionReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForSetParameterReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForGetParameterReply(DeviceCommandId_t *foundId); - ReturnValue_t scanForTmReply(DeviceCommandId_t *foundId); - - /** - * @brief Fills command buffer with data to ping the star tracker - */ - void preparePingRequest(); - - /** - * @brief Fills command buffer with data to request the time telemetry. - */ - void prepareTimeRequest(); - - /** - * @brief Handles all received event messages - */ - void handleEvent(EventMessage* eventMessage); - - /** - * @brief Executes the write command - * - * @param commandData Pointer to received command data - * @param commandDataLen Size of received command data - * - * @return RETURN_OK if start of execution was successful, otherwise error return value - */ - ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Starts the execution of the fpga download command - * - * @param commandData Pointer to buffer with command data - * @param commandDataLen Size of received command - */ - ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Extracts information for flash-read-command from TC data and starts execution of - * flash-read-procedure - * - * @param commandData Pointer to received command data - * @param commandDataLen Size of received command data - * - * @return RETURN_OK if start of execution was successful, otherwise error return value - */ - ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with data to boot image (works only when star tracker is - * in bootloader mode). - */ - void prepareBootCommand(); - - /** - * @brief Fills command buffer with command to erase a flash region - */ - ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to unlock flash region - */ - ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to get the checksum of a flash part - */ - ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to set the unix time - */ - ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to request a centroid - */ - ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to upload a centroid for testing purpose - */ - ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills the command buffer with the command to take an image. - */ - void prepareTakeImageCommand(const uint8_t* commandData); - - /** - * @brief Fills command buffer with data to request the version telemetry packet - */ - void prepareVersionRequest(); - - /** - * @brief Fills the command buffer with data to request the interface telemetry packet. - */ - void prepareInterfaceRequest(); - - /** - * @brief Fills the command buffer with data to request the power telemetry packet. - */ - void preparePowerRequest(); - - /** - * @brief Fills command buffer with data to reboot star tracker. - */ - void prepareRebootCommand(); - - /** - * @brief Fills command buffer with data to subscribe to a telemetry packet. - * - * @param tmId The ID of the telemetry packet to subscribe to - */ - void prepareSubscriptionCommand(const uint8_t* tmId); - - /** - * @brief Fills command buffer with data to request solution telemtry packet (contains - * attitude information) - */ - void prepareSolutionRequest(); - - /** - * @brief Fills command buffer with data to request temperature from star tracker - */ - void prepareTemperatureRequest(); - - /** - * @brief Fills command buffer with data to request histogram - */ - void prepareHistogramRequest(); - - void prepareContrastRequest(); - - /** - * @brief Fills command buffer with command to reset the error signal of the star tracker - */ - void prepareErrorResetRequest(); - - /** - * @brief Reads parameters from json file specified by string in commandData and - * prepares the command to apply the parameter set to the star tracker - * - * @param commandData Contains string with file name - * @param commandDataLen Length of command - * @param paramSet The object defining the command generation - * - * @return RETURN_OK if successful, otherwise error return Value - */ - ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, - ArcsecJsonParamBase& paramSet); - - /** - * @brief Fills command buffer with data to request matched star. - */ - ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief Fills command buffer with data to request matched star coordinates. - */ - 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); - - /** - * @brief With this command the FPGA update will be applied to the star tracker - */ - ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Will fill the command buffer with the command to request the set camera parameters. - */ - ReturnValue_t prepareRequestCameraParams(); - - /** - * @brief Will fill the command buffer with the command to request the set limits. - */ - ReturnValue_t prepareRequestLimitsParams(); - - /** - * @brief Will fill the command buffer with the command to request the set blob parameters. - */ - ReturnValue_t prepareRequestBlobParams(); - - /** - * @brief Handles action replies with datasets. - */ - ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size); - - /** - * @brief Default function to handle action replies - */ - ReturnValue_t handleActionReply(); - - /** - * @brief Handles reply to upload centroid command - */ - ReturnValue_t handleUploadCentroidReply(); - - /** - * @brief Handles reply to erase command - */ - ReturnValue_t handleEraseReply(); - - /** - * @brief Handles reply to checksum command - */ - ReturnValue_t handleChecksumReply(); - - /** - * @brief Handles all set parameter replies - */ - ReturnValue_t handleSetParamReply(); - - ReturnValue_t handlePingReply(); - - ReturnValue_t handleParamRequest(LocalPoolDataSetBase& dataset, size_t size); - - /** - * @brief Checks the loaded program by means of the version set - */ - ReturnValue_t checkProgram(); - - /** - * @brief Handles the startup state machine - */ - void handleStartup(const uint8_t* parameterId); - - /** - * @brief Handles telemtry replies and fills the appropriate dataset - * - * @param dataset Dataset where reply data will be written to - * @param size Size of the dataset - * - * @return RETURN_OK if successful, otherwise error return value - */ - ReturnValue_t handleTm(LocalPoolDataSetBase& dataset, size_t size); +class StarTrackerHandler : public DeviceHandlerBase { + public: + /** + * @brief Constructor + * + * @param objectId + * @param comIF + * @param comCookie + * @param gpioComIF Pointer to gpio communication interface + * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled + * to high to enable the device. + */ + StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + StrHelper* strHelper); + virtual ~StarTrackerHandler(); + + ReturnValue_t initialize() override; + + /** + * @brief Overwrite this function from DHB to handle commands executed by the str image + * loader task. + */ + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + + void performOperationHook() override; + + protected: + void doStartUp() override; + void doShutDown() override; + void doOffActivity() override; + 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; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + /** + * @brief Overwritten here to always read all available data from the UartComIF. + */ + virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + virtual ReturnValue_t doSendReadHook() override; + + private: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] Received reply is too short + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Received reply with invalid CRC + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Image loader executing + static const ReturnValue_t IMAGE_LOADER_EXECUTING = MAKE_RETURN_CODE(0xB2); + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; + + //! [EXPORT] : [COMMENT] Status in temperature reply signals error + static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Ping command failed + static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Status in version reply signals error + static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Status in interface reply signals error + static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Status in power reply signals error + static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error + static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status of reply to action command signals error + static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Received upload image command with invalid position field + static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position + static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); + //! [EXPORT] : [COMMENT] Received upload image command with invalid length + static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); + //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length + static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); + //! [EXPORT] : [COMMENT] Name of file received with command is too long + static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); + //! [EXPORT] : [COMMENT] Received version reply with invalid program ID + static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); + //! [EXPORT] : [COMMENT] Status field reply signals error + 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) + 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); + //! [EXPORT] : [COMMENT] Region mismatch between send and received data + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Address mismatch between send and received data + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Length field mismatch between send and received data + static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] Specified file does not exist + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id + static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field + static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); + //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID + static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); + + static const size_t MAX_PATH_SIZE = 50; + static const size_t MAX_FILE_NAME = 30; + + // position (uint32) + 1024 image data + static const size_t UPLOAD_COMMAND_LEN = 1028; + // Max valid position value in upload image command + static const uint16_t MAX_POSITION = 4095; + static const uint8_t STATUS_OFFSET = 1; + static const uint8_t PARAMS_OFFSET = 1; + static const uint8_t TICKS_OFFSET = 2; + static const uint8_t TIME_OFFSET = 6; + static const uint8_t TM_DATA_FIELD_OFFSET = 14; + static const uint8_t PARAMETER_ID_OFFSET = 0; + static const uint8_t ACTION_ID_OFFSET = 0; + static const uint8_t ACTION_DATA_OFFSET = 2; + // Ping request will reply ping with this ID (data field) + static const uint32_t PING_ID = 0x55; + static const uint32_t BOOT_REGION_ID = 1; + static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; + static const uint32_t MUTEX_TIMEOUT = 20; + static const uint32_t BOOT_TIMEOUT = 1000; + + class WriteCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t FILE_OFFSET = 5; + // Minimum length of a write command (region, address and filename) + static const size_t MIN_LENGTH = 7; + }; + + class ReadCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + static const uint8_t FILE_OFFSET = 9; + // Minimum length of a read command (region, address, length and filename) + static const size_t MIN_LENGTH = 11; + }; + + class EraseCmd { + public: + static const uint8_t LENGTH = 1; + uint8_t rememberRegion = 0; + }; + + EraseCmd eraseCmd; + + class UnlockCmd { + public: + static const uint8_t CODE_OFFSET = 1; + }; + + class ChecksumCmd { + public: + static const uint8_t ADDRESS_OFFSET = 1; + static const uint8_t LENGTH_OFFSET = 5; + // Length of checksum command + static const size_t LENGTH = 9; + uint8_t rememberRegion = 0; + uint32_t rememberAddress = 0; + uint32_t rememberLength = 0; + }; + + ChecksumCmd checksumCmd; + + class SetTimeCmd { + public: + static const uint8_t LENGTH = 8; + }; + + class DownloadCentroidCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class UploadCentroid { + public: + uint8_t rememberId = 0; + }; + + UploadCentroid uploadCentroid; + + class DownloadMatchedStarCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadDbImageCmd { + public: + static const uint8_t LENGTH = 1; + }; + + class DownloadBlobPixCmd { + public: + static const uint8_t LENGTH = 2; + static const uint8_t NORMAL = 0; + static const uint8_t FAST = 1; + }; + + class FpgaDownloadCmd { + public: + static const uint8_t MIN_LENGTH = 10; + }; + + class FpgaActionCmd { + public: + static const uint8_t LENGTH = 1; + static const uint8_t ID = 3; + }; + + MessageQueueIF* eventQueue = nullptr; + + ArcsecDatalinkLayer dataLinkLayer; + + StarTracker::TemperatureSet temperatureSet; + StarTracker::VersionSet versionSet; + StarTracker::PowerSet powerSet; + StarTracker::InterfaceSet interfaceSet; + StarTracker::TimeSet timeSet; + StarTracker::SolutionSet solutionSet; + StarTracker::HistogramSet histogramSet; + StarTracker::ContrastSet contrastSet; + StarTracker::ChecksumSet checksumSet; + StarTracker::DownloadCentroidSet downloadCentroidSet; + StarTracker::DownloadMatchedStar downloadMatchedStar; + StarTracker::DownloadDBImage downloadDbImage; + StarTracker::DownloadBlobPixel downloadBlobPixel; + StarTracker::CameraSet cameraSet; + StarTracker::LimitsSet limitsSet; + StarTracker::BlobSet blobSet; + + // Pointer to object responsible for uploading and downloading images to/from the star tracker + StrHelper* strHelper = nullptr; + + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + + // Countdown to insert delay for star tracker to switch from bootloader to firmware program + Countdown bootCountdown; + + std::string paramJsonFile = "/mnt/sd0/startracker/full.json"; + + enum class InternalState { TEMPERATURE_REQUEST }; + + InternalState internalState = InternalState::TEMPERATURE_REQUEST; + + enum class StartupState { + IDLE, + CHECK_BOOT_STATE, + BOOT, + BOOT_DELAY, + LIMITS, + TRACKING, + MOUNTING, + CAMERA, + BLOB, + CENTROIDING, + LISA, + MATCHING, + VALIDATION, + ALGO, + WAIT_FOR_EXECUTION, + DONE + }; + + StartupState startupState = StartupState::IDLE; + + bool strHelperExecuting = false; + + /** + * @brief Handles internal state + */ + void handleInternalState(); + + /** + * @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution. + * + * @param actionId Action id of command to execute + */ + ReturnValue_t checkMode(ActionId_t actionId); + + /** + * @brief This function initializes the serial link ip protocol struct slipInfo. + */ + void slipInit(); + + ReturnValue_t scanForActionReply(DeviceCommandId_t* foundId); + ReturnValue_t scanForSetParameterReply(DeviceCommandId_t* foundId); + ReturnValue_t scanForGetParameterReply(DeviceCommandId_t* foundId); + ReturnValue_t scanForTmReply(DeviceCommandId_t* foundId); + + /** + * @brief Fills command buffer with data to ping the star tracker + */ + void preparePingRequest(); + + /** + * @brief Fills command buffer with data to request the time telemetry. + */ + void prepareTimeRequest(); + + /** + * @brief Handles all received event messages + */ + void handleEvent(EventMessage* eventMessage); + + /** + * @brief Executes the write command + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeWriteCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Starts the execution of the fpga download command + * + * @param commandData Pointer to buffer with command data + * @param commandDataLen Size of received command + */ + ReturnValue_t executeFpgaDownloadCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Extracts information for flash-read-command from TC data and starts execution of + * flash-read-procedure + * + * @param commandData Pointer to received command data + * @param commandDataLen Size of received command data + * + * @return RETURN_OK if start of execution was successful, otherwise error return value + */ + ReturnValue_t executeReadCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with data to boot image (works only when star tracker is + * in bootloader mode). + */ + void prepareBootCommand(); + + /** + * @brief Fills command buffer with command to erase a flash region + */ + ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to unlock flash region + */ + ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to get the checksum of a flash part + */ + ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to set the unix time + */ + ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to request a centroid + */ + ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills command buffer with command to upload a centroid for testing purpose + */ + ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Fills the command buffer with the command to take an image. + */ + void prepareTakeImageCommand(const uint8_t* commandData); + + /** + * @brief Fills command buffer with data to request the version telemetry packet + */ + void prepareVersionRequest(); + + /** + * @brief Fills the command buffer with data to request the interface telemetry packet. + */ + void prepareInterfaceRequest(); + + /** + * @brief Fills the command buffer with data to request the power telemetry packet. + */ + void preparePowerRequest(); + + /** + * @brief Fills command buffer with data to reboot star tracker. + */ + void prepareRebootCommand(); + + /** + * @brief Fills command buffer with data to subscribe to a telemetry packet. + * + * @param tmId The ID of the telemetry packet to subscribe to + */ + void prepareSubscriptionCommand(const uint8_t* tmId); + + /** + * @brief Fills command buffer with data to request solution telemtry packet (contains + * attitude information) + */ + void prepareSolutionRequest(); + + /** + * @brief Fills command buffer with data to request temperature from star tracker + */ + void prepareTemperatureRequest(); + + /** + * @brief Fills command buffer with data to request histogram + */ + void prepareHistogramRequest(); + + void prepareContrastRequest(); + + /** + * @brief Fills command buffer with command to reset the error signal of the star tracker + */ + void prepareErrorResetRequest(); + + /** + * @brief Reads parameters from json file specified by string in commandData and + * prepares the command to apply the parameter set to the star tracker + * + * @param commandData Contains string with file name + * @param commandDataLen Length of command + * @param paramSet The object defining the command generation + * + * @return RETURN_OK if successful, otherwise error return Value + */ + ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, + ArcsecJsonParamBase& paramSet); + + /** + * @brief Fills command buffer with data to request matched star. + */ + ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, + size_t commandDataLen); + + /** + * @brief Fills command buffer with data to request matched star coordinates. + */ + 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); + + /** + * @brief With this command the FPGA update will be applied to the star tracker + */ + ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); + + /** + * @brief Will fill the command buffer with the command to request the set camera parameters. + */ + ReturnValue_t prepareRequestCameraParams(); + + /** + * @brief Will fill the command buffer with the command to request the set limits. + */ + ReturnValue_t prepareRequestLimitsParams(); + + /** + * @brief Will fill the command buffer with the command to request the set blob parameters. + */ + ReturnValue_t prepareRequestBlobParams(); + + /** + * @brief Handles action replies with datasets. + */ + ReturnValue_t handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size); + + /** + * @brief Default function to handle action replies + */ + ReturnValue_t handleActionReply(); + + /** + * @brief Handles reply to upload centroid command + */ + ReturnValue_t handleUploadCentroidReply(); + + /** + * @brief Handles reply to erase command + */ + ReturnValue_t handleEraseReply(); + + /** + * @brief Handles reply to checksum command + */ + ReturnValue_t handleChecksumReply(); + + /** + * @brief Handles all set parameter replies + */ + ReturnValue_t handleSetParamReply(); + + ReturnValue_t handlePingReply(); + + ReturnValue_t handleParamRequest(LocalPoolDataSetBase& dataset, size_t size); + + /** + * @brief Checks the loaded program by means of the version set + */ + ReturnValue_t checkProgram(); + + /** + * @brief Handles the startup state machine + */ + void handleStartup(const uint8_t* parameterId); + + /** + * @brief Handles telemtry replies and fills the appropriate dataset + * + * @param dataset Dataset where reply data will be written to + * @param size Size of the dataset + * + * @return RETURN_OK if successful, otherwise error return value + */ + ReturnValue_t handleTm(LocalPoolDataSetBase& dataset, size_t size); }; #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp index 9c33e1c9..b912c03e 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.cpp @@ -1,716 +1,689 @@ #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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::LIMITS); - offset = 2; - result = getParam(arcseckeys::ACTION, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FPGA18CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA25CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FPGA10CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCUCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS21CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSPIXCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS33CURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOSVRESCURRENT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CMOS_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MCU_TEMPERATURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LIMITS); + offset = 2; + result = getParam(arcseckeys::ACTION, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FPGA18CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA25CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FPGA10CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCUCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS21CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSPIXCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS33CURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOSVRESCURRENT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CMOS_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MCU_TEMPERATURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + 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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::TRACKING); - offset = 2; - result = getParam(arcseckeys::THIN_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRACKER_CHOICE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::TRACKING); + offset = 2; + result = getParam(arcseckeys::THIN_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OUTLIER_THRESHOLD_QUEST, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRACKER_CHOICE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + 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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::MOUNTING); - offset = 2; - result = getParam(arcseckeys::qw, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qx, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qy, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::qz, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MOUNTING); + offset = 2; + result = getParam(arcseckeys::qw, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qx, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qy, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::qz, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + 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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::CAMERA); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FOCALLENGTH, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::EXPOSURE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::INTERVAL, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::OFFSET, param); - if (result != RETURN_OK) { - return result; - } - addint16(param, buffer + offset); - offset += sizeof(int16_t); - result = getParam(arcseckeys::PGAGAIN, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ADCGAIN, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_1, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_1, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_2, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_2, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_3, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_3, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_4, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_4, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_5, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_5, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_6, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_6, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_7, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_7, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::REG_8, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::VAL_8, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FREQ_1, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FREQ_2, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::CAMERA); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FOCALLENGTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::EXPOSURE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::INTERVAL, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::OFFSET, param); + if (result != RETURN_OK) { + return result; + } + addint16(param, buffer + offset); + offset += sizeof(int16_t); + result = getParam(arcseckeys::PGAGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ADCGAIN, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_1, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_2, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_3, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_4, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_5, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_6, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_7, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::REG_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::VAL_8, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FREQ_1, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FREQ_2, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + 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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::BLOB); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_DISTANCE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); - if (result != RETURN_OK) { - return result; - } - adduint16(param, buffer + offset); - offset += sizeof(uint16_t); - result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); - if (result != RETURN_OK) { - return result; - } - adduint32(param, buffer + offset); - offset += sizeof(uint32_t); - result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::DARK_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::ENABLE_CONTRAST, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::BIN_MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::BLOB); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_DISTANCE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NEIGHBOUR_BRIGHT_PIXELS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MIN_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_TOTAL_VALUE, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MIN_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_BRIGHT_NEIGHBOURS, param); + if (result != RETURN_OK) { + return result; + } + adduint16(param, buffer + offset); + offset += sizeof(uint16_t); + result = getParam(arcseckeys::MAX_PIXEL_TO_CONSIDER, param); + if (result != RETURN_OK) { + return result; + } + adduint32(param, buffer + offset); + offset += sizeof(uint32_t); + result = getParam(arcseckeys::SIGNAL_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::DARK_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_HISTOGRAM, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::ENABLE_CONTRAST, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::BIN_MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + 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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::CENTROIDING); - offset = 2; - result = getParam(arcseckeys::ENABLE_FILTER, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MAX_QUALITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_QUALITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_INTENSITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_INTENSITY, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_MAGNITUDE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::GAUSSIAN_CMAX, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::GAUSSIAN_CMIN, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_00, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_01, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_10, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::TRANSMATRIX_11, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::CENTROIDING); + offset = 2; + result = getParam(arcseckeys::ENABLE_FILTER, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_QUALITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_INTENSITY, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_MAGNITUDE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMAX, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::GAUSSIAN_CMIN, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_00, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_01, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_10, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::TRANSMATRIX_11, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + 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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::LISA); - offset = 2; - result = getParam(arcseckeys::PREFILTER_DIST_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::PREFILTER_ANGLE_THRESHOLD, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FOV_WIDTH, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FOV_HEIGHT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::FLOAT_STAR_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::CLOSE_STAR_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_CLOSE_STAR_COUNT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_FRACTION_CLOSE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::RATING_WEIGHT_DB_STAR_COUNT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MAX_COMBINATIONS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::NR_STARS_STOP, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::FRACTION_CLOSE_STOP, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::LISA); + offset = 2; + result = getParam(arcseckeys::PREFILTER_DIST_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::PREFILTER_ANGLE_THRESHOLD, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_WIDTH, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FOV_HEIGHT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::FLOAT_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::CLOSE_STAR_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_CLOSE_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_FRACTION_CLOSE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::RATING_WEIGHT_DB_STAR_COUNT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MAX_COMBINATIONS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::NR_STARS_STOP, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::FRACTION_CLOSE_STOP, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + 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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::MATCHING); - offset = 2; - result = getParam(arcseckeys::SQUARED_DISTANCE_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::SQUARED_SHIFT_LIMIT, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::MATCHING); + offset = 2; + result = getParam(arcseckeys::SQUARED_DISTANCE_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::SQUARED_SHIFT_LIMIT, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + 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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::VALIDATION); - offset = 2; - result = getParam(arcseckeys::STABLE_COUNT, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::MAX_DIFFERENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_TRACKER_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::MIN_MATCHED_STARS, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::VALIDATION); + offset = 2; + result = getParam(arcseckeys::STABLE_COUNT, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::MAX_DIFFERENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_TRACKER_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::MIN_MATCHED_STARS, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } 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; - uint8_t offset = 0; - std::string param; - addSetParamHeader(buffer, StarTracker::ID::ALGO); - offset = 2; - result = getParam(arcseckeys::MODE, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::L2T_MIN_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::L2T_MIN_MATCHED, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - offset += sizeof(uint8_t); - result = getParam(arcseckeys::T2L_MIN_CONFIDENCE, param); - if (result != RETURN_OK) { - return result; - } - addfloat(param, buffer + offset); - offset += sizeof(float); - result = getParam(arcseckeys::T2L_MIN_MATCHED, param); - if (result != RETURN_OK) { - return result; - } - adduint8(param, buffer + offset); - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + uint8_t offset = 0; + std::string param; + addSetParamHeader(buffer, StarTracker::ID::ALGO); + offset = 2; + result = getParam(arcseckeys::MODE, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::L2T_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::L2T_MIN_MATCHED, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + offset += sizeof(uint8_t); + result = getParam(arcseckeys::T2L_MIN_CONFIDENCE, param); + if (result != RETURN_OK) { + return result; + } + addfloat(param, buffer + offset); + offset += sizeof(float); + result = getParam(arcseckeys::T2L_MIN_MATCHED, param); + if (result != RETURN_OK) { + return result; + } + adduint8(param, buffer + offset); + return RETURN_OK; } diff --git a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h index 868c18ea..96c52fa2 100644 --- a/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h +++ b/bsp_q7s/devices/startracker/StarTrackerJsonCommands.h @@ -9,207 +9,168 @@ #include -#include "fsfw/serviceinterface/ServiceInterface.h" #include "ArcsecJsonParamBase.h" - +#include "fsfw/serviceinterface/ServiceInterface.h" /** * @brief Generates command to set the limit parameters * */ class Limits : public ArcsecJsonParamBase { -public: + public: + Limits(); - Limits(); + size_t getSize(); - size_t getSize(); + private: + static const size_t COMMAND_SIZE = 43; -private: - - static const size_t COMMAND_SIZE = 43; - - virtual ReturnValue_t createCommand(uint8_t* buffer) override; + virtual ReturnValue_t createCommand(uint8_t* buffer) override; }; - /** * @brief Generates the command to configure the tracking algorithm. * */ class Tracking : public ArcsecJsonParamBase { -public: + public: + Tracking(); - Tracking(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 15; - - ReturnValue_t createCommand(uint8_t* buffer) override; + 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: + public: + Mounting(); - Mounting(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 18; - - ReturnValue_t createCommand(uint8_t* buffer) override; + 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: + public: + Camera(); - Camera(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 43; - - ReturnValue_t createCommand(uint8_t* buffer) override; + 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: + public: + Blob(); - Blob(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 24; - - ReturnValue_t createCommand(uint8_t* buffer) override; + 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: + public: + Centroiding(); - Centroiding(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 47; - - ReturnValue_t createCommand(uint8_t* buffer) override; + 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: + public: + Lisa(); - Lisa(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 48; - - ReturnValue_t createCommand(uint8_t* buffer) override; + 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: + public: + Matching(); - Matching(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 10; - - ReturnValue_t createCommand(uint8_t* buffer) override; + 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: + public: + Validation(); - Validation(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 12; - - ReturnValue_t createCommand(uint8_t* buffer) override; + 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. * */ class Algo : public ArcsecJsonParamBase { -public: + public: + Algo(); - Algo(); + size_t getSize(); - size_t getSize(); - -private: - - static const size_t COMMAND_SIZE = 13; - - ReturnValue_t createCommand(uint8_t* buffer) override; + private: + static const size_t COMMAND_SIZE = 13; + ReturnValue_t createCommand(uint8_t* buffer) override; }; #endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_STARTRACKERJSONCOMMANDS_H_ */ diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 4a3cef13..eedd0241 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -1,702 +1,672 @@ #include "StrHelper.h" +#include +#include + #include "mission/utility/Timestamp.h" -#include -#include +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(); - if (sdcMan == nullptr) { - sif::warning << "StrHelper::initialize: Invalid SD Card Manager" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + sdcMan = SdCardManager::instance(); + if (sdcMan == nullptr) { + sif::warning << "StrHelper::initialize: Invalid SD Card Manager" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; - semaphore.acquire(); - while(true) { - switch(internalState) { - case InternalState::IDLE: { - semaphore.acquire(); - break; + ReturnValue_t result = RETURN_OK; + semaphore.acquire(); + while (true) { + switch (internalState) { + case InternalState::IDLE: { + semaphore.acquire(); + break; + } + case InternalState::UPLOAD_IMAGE: { + result = performImageUpload(); + if (result == RETURN_OK) { + triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); + } else { + triggerEvent(IMAGE_UPLOAD_FAILED); } - case InternalState::UPLOAD_IMAGE: { - result = performImageUpload(); - if (result == RETURN_OK){ - triggerEvent(IMAGE_UPLOAD_SUCCESSFUL); - } - else { - triggerEvent(IMAGE_UPLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::DOWNLOAD_IMAGE: { + result = performImageDownload(); + if (result == RETURN_OK) { + triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); + } else { + triggerEvent(IMAGE_DOWNLOAD_FAILED); } - case InternalState::DOWNLOAD_IMAGE: { - result = performImageDownload(); - if (result == RETURN_OK){ - triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL); - } - else { - triggerEvent(IMAGE_DOWNLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::FLASH_WRITE: { + result = performFlashWrite(); + if (result == RETURN_OK) { + triggerEvent(FLASH_WRITE_SUCCESSFUL); + } else { + triggerEvent(FLASH_WRITE_FAILED); } - case InternalState::FLASH_WRITE: { - result = performFlashWrite(); - if (result == RETURN_OK){ - triggerEvent(FLASH_WRITE_SUCCESSFUL); - } - else { - triggerEvent(FLASH_WRITE_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::FLASH_READ: { + result = performFlashRead(); + if (result == RETURN_OK) { + triggerEvent(FLASH_READ_SUCCESSFUL); + } else { + triggerEvent(FLASH_READ_FAILED); } - case InternalState::FLASH_READ: { - result = performFlashRead(); - if (result == RETURN_OK){ - triggerEvent(FLASH_READ_SUCCESSFUL); - } - else { - triggerEvent(FLASH_READ_FAILED); - } - internalState = InternalState::IDLE; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::DOWNLOAD_FPGA_IMAGE: { + result = performFpgaDownload(); + if (result == RETURN_OK) { + triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL); + } else { + triggerEvent(FPGA_DOWNLOAD_FAILED); } - case InternalState::DOWNLOAD_FPGA_IMAGE: { - result = performFpgaDownload(); - if (result == RETURN_OK){ - triggerEvent(FPGA_DOWNLOAD_SUCCESSFUL); - } - else { - triggerEvent(FPGA_DOWNLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; - } - case InternalState::UPLOAD_FPGA_IMAGE: { - result = performFpgaUpload(); - if (result == RETURN_OK){ - triggerEvent(FPGA_UPLOAD_SUCCESSFUL); - } - else { - triggerEvent(FPGA_UPLOAD_FAILED); - } - internalState = InternalState::IDLE; - break; - } - default: - sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; - break; + internalState = InternalState::IDLE; + break; + } + case InternalState::UPLOAD_FPGA_IMAGE: { + result = performFpgaUpload(); + if (result == RETURN_OK) { + triggerEvent(FPGA_UPLOAD_SUCCESSFUL); + } else { + triggerEvent(FPGA_UPLOAD_FAILED); } + internalState = InternalState::IDLE; + break; + } + default: + sif::debug << "StrHelper::performOperation: Invalid state" << std::endl; + break; } + } } ReturnValue_t StrHelper::setComIF(DeviceCommunicationIF* communicationInterface_) { - uartComIF = dynamic_cast(communicationInterface_); - if (uartComIF == nullptr) { - sif::warning << "StrHelper::initialize: Invalid uart com if" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + uartComIF = dynamic_cast(communicationInterface_); + if (uartComIF == nullptr) { + sif::warning << "StrHelper::initialize: Invalid uart com if" << std::endl; + return RETURN_FAILED; + } + 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); - if (result != RETURN_OK) { - return result; - } - uploadImage.uploadFile = fullname; - if(not std::filesystem::exists(fullname)) { - return FILE_NOT_EXISTS; - } - internalState = InternalState::UPLOAD_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + ReturnValue_t result = checkPath(fullname); + if (result != RETURN_OK) { + return result; + } + uploadImage.uploadFile = fullname; + if (not std::filesystem::exists(fullname)) { + return FILE_NOT_EXISTS; + } + internalState = InternalState::UPLOAD_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startImageDownload(std::string path) { - ReturnValue_t result = checkPath(path); - if (result != RETURN_OK) { - return result; - } - if(not std::filesystem::exists(path)) { - return PATH_NOT_EXISTS; - } - downloadImage.path = path; - internalState = InternalState::DOWNLOAD_IMAGE; - terminate = false; - semaphore.release(); - return RETURN_OK; + ReturnValue_t result = checkPath(path); + if (result != RETURN_OK) { + return result; + } + if (not std::filesystem::exists(path)) { + return PATH_NOT_EXISTS; + } + downloadImage.path = path; + internalState = InternalState::DOWNLOAD_IMAGE; + terminate = false; + semaphore.release(); + return RETURN_OK; } -void StrHelper::stopProcess() { - terminate = true; +void StrHelper::stopProcess() { terminate = true; } + +void StrHelper::setDownloadImageName(std::string filename) { downloadImage.filename = filename; } + +void StrHelper::setFlashReadFilename(std::string filename) { flashRead.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 result = checkPath(fullname); + if (result != RETURN_OK) { + return result; + } + flashWrite.fullname = fullname; + if (not std::filesystem::exists(flashWrite.fullname)) { + return FILE_NOT_EXISTS; + } + flashWrite.address = address; + flashWrite.region = region; + internalState = InternalState::FLASH_WRITE; + semaphore.release(); + terminate = false; + return RETURN_OK; } -void StrHelper::setDownloadImageName(std::string filename) { - downloadImage.filename = filename; -} - -void StrHelper::setFlashReadFilename(std::string filename) { - flashRead.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 result = checkPath(fullname); - if (result != RETURN_OK) { - return result; - } - flashWrite.fullname = fullname; - if(not std::filesystem::exists(flashWrite.fullname)) { - return FILE_NOT_EXISTS; - } - flashWrite.address = address; - flashWrite.region = region; - internalState = InternalState::FLASH_WRITE; - semaphore.release(); - terminate = false; - return RETURN_OK; -} - -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; - } - flashRead.path = path; - if(not std::filesystem::exists(flashRead.path)) { - return FILE_NOT_EXISTS; - } - flashRead.address = address; - flashRead.region = region; - flashRead.size = length; - internalState = InternalState::FLASH_READ; - semaphore.release(); - terminate = false; - return RETURN_OK; +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; + } + flashRead.path = path; + if (not std::filesystem::exists(flashRead.path)) { + return FILE_NOT_EXISTS; + } + flashRead.address = address; + flashRead.region = region; + flashRead.size = length; + internalState = InternalState::FLASH_READ; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startFpgaDownload(std::string path, uint32_t startPosition, - uint32_t length) { - fpgaDownload.path = path; - fpgaDownload.startPosition = startPosition; - fpgaDownload.length = length; - internalState = InternalState::DOWNLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + uint32_t length) { + fpgaDownload.path = path; + fpgaDownload.startPosition = startPosition; + fpgaDownload.length = length; + internalState = InternalState::DOWNLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::startFpgaUpload(std::string uploadFile) { - fpgaUpload.uploadFile = uploadFile; - internalState = InternalState::UPLOAD_FPGA_IMAGE; - semaphore.release(); - terminate = false; - return RETURN_OK; + fpgaUpload.uploadFile = uploadFile; + internalState = InternalState::UPLOAD_FPGA_IMAGE; + semaphore.release(); + terminate = false; + return RETURN_OK; } ReturnValue_t StrHelper::performImageDownload() { - ReturnValue_t result; - struct DownloadActionRequest downloadReq; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename ; - std::ofstream file(image, std::ios_base::app | std::ios_base::out); - if(not std::filesystem::exists(image)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct DownloadActionRequest downloadReq; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string image = downloadImage.path + "/" + timestamp.str() + downloadImage.filename; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } + downloadReq.position = 0; + while (downloadReq.position < ImageDownload::LAST_POSITION) { + if (terminate) { + return RETURN_OK; } - downloadReq.position = 0; - while(downloadReq.position < ImageDownload::LAST_POSITION) { - if (terminate) { - return RETURN_OK; - } - arc_pack_download_action_req(&downloadReq, commandBuffer, &size); - result = sendAndRead(size, downloadReq.position); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkActionReply(); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkReplyPosition(downloadReq.position); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + IMAGE_DATA_OFFSET), - IMAGE_DATA_SIZE); - downloadReq.position++; - retries = 0; + arc_pack_download_action_req(&downloadReq, commandBuffer, &size); + result = sendAndRead(size, downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; } - file.close(); - return RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkReplyPosition(downloadReq.position); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + IMAGE_DATA_OFFSET), + IMAGE_DATA_SIZE); + downloadReq.position++; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performImageUpload() { - ReturnValue_t result = RETURN_OK; - uint32_t size = 0; - uint32_t imageSize = 0; - struct UploadActionRequest uploadReq; - uploadReq.position = 0; - std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); - if (not std::filesystem::exists(uploadImage.uploadFile)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; + ReturnValue_t result = RETURN_OK; + uint32_t size = 0; + uint32_t imageSize = 0; + struct UploadActionRequest uploadReq; + uploadReq.position = 0; + std::memset(&uploadReq.data, 0, sizeof(uploadReq.data)); + if (not std::filesystem::exists(uploadImage.uploadFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); + // Set position of next character to end of file input stream + file.seekg(0, file.end); + // tellg returns position of character in input stream + imageSize = file.tellg(); + while ((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { + if (terminate) { + return RETURN_OK; } - std::ifstream file(uploadImage.uploadFile, std::ifstream::binary); - // Set position of next character to end of file input stream - file.seekg(0, file.end); - // tellg returns position of character in input stream - imageSize = file.tellg(); - while((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { - if (terminate) { - return RETURN_OK; - } - file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); - file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); - arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); - result = sendAndRead(size, uploadReq.position); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - uploadReq.position++; - } - std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); - uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); - file.read(reinterpret_cast(uploadReq.data), remainder); - file.close(); - uploadReq.position++; + file.read(reinterpret_cast(uploadReq.data), SIZE_IMAGE_PART); arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); result = sendAndRead(size, uploadReq.position); if (result != RETURN_OK) { - return RETURN_FAILED; + return RETURN_FAILED; } result = checkActionReply(); if (result != RETURN_OK) { - return result; + return result; } - return RETURN_OK; + uploadReq.position++; + } + std::memset(uploadReq.data, 0, sizeof(uploadReq.data)); + uint32_t remainder = imageSize - uploadReq.position * SIZE_IMAGE_PART; + file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); + file.read(reinterpret_cast(uploadReq.data), remainder); + file.close(); + uploadReq.position++; + arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); + result = sendAndRead(size, uploadReq.position); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkActionReply(); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } ReturnValue_t StrHelper::performFlashWrite() { - ReturnValue_t result = RETURN_OK; - uint32_t size = 0; - uint32_t remainingBytes = 0; - uint32_t fileSize = 0; - struct WriteActionRequest req; - if (not std::filesystem::exists(flashWrite.fullname)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; - } - std::ifstream file(flashWrite.fullname, std::ifstream::binary); - file.seekg(0, file.end); - fileSize = file.tellg(); - remainingBytes = fileSize; - req.region = flashWrite.region; - req.address = flashWrite.address; - req.length = MAX_FLASH_DATA; - while(remainingBytes >= MAX_FLASH_DATA) { - if (terminate) { - return RETURN_OK; - } - file.seekg(fileSize - remainingBytes, file.beg); - file.read(reinterpret_cast(req.data), MAX_FLASH_DATA); - arc_pack_write_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.address); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkFlashActionReply(req.region, req.address, req.length); - if (result != RETURN_OK) { - return result; - } - remainingBytes = remainingBytes - MAX_FLASH_DATA; + ReturnValue_t result = RETURN_OK; + uint32_t size = 0; + uint32_t remainingBytes = 0; + uint32_t fileSize = 0; + struct WriteActionRequest req; + if (not std::filesystem::exists(flashWrite.fullname)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWrite.fullname, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + remainingBytes = fileSize; + req.region = flashWrite.region; + req.address = flashWrite.address; + req.length = MAX_FLASH_DATA; + while (remainingBytes >= MAX_FLASH_DATA) { + if (terminate) { + return RETURN_OK; } file.seekg(fileSize - remainingBytes, file.beg); - file.read(reinterpret_cast(req.data), remainingBytes); - file.close(); + file.read(reinterpret_cast(req.data), MAX_FLASH_DATA); arc_pack_write_action_req(&req, commandBuffer, &size); result = sendAndRead(size, req.address); if (result != RETURN_OK) { - return RETURN_FAILED; + return RETURN_FAILED; } result = checkFlashActionReply(req.region, req.address, req.length); if (result != RETURN_OK) { - return result; + return result; } - return RETURN_OK; + remainingBytes = remainingBytes - MAX_FLASH_DATA; + } + file.seekg(fileSize - remainingBytes, file.beg); + file.read(reinterpret_cast(req.data), remainingBytes); + file.close(); + arc_pack_write_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFlashActionReply(req.region, req.address, req.length); + if (result != RETURN_OK) { + return result; + } + return RETURN_OK; } ReturnValue_t StrHelper::performFlashRead() { - ReturnValue_t result; - struct ReadActionRequest req; - uint32_t bytesRead = 0; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename ; - std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); - if (not std::filesystem::exists(fullname)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct ReadActionRequest req; + uint32_t bytesRead = 0; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string fullname = flashRead.path + "/" + timestamp.str() + flashRead.filename; + std::ofstream file(fullname, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(fullname)) { + return FILE_CREATION_FAILED; + } + req.region = flashRead.region; + while (bytesRead < flashRead.size) { + if (terminate) { + return RETURN_OK; } - req.region = flashRead.region; - while(bytesRead < flashRead.size) { - if (terminate) { - return RETURN_OK; - } - if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) { - req.length = flashRead.size - bytesRead; - } - else { - req.length = MAX_FLASH_DATA; - } - req.address = flashRead.address + bytesRead; - arc_pack_read_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.address); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkActionReply(); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkFlashActionReply(req.region, req.address, req.length); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET), - req.length); - bytesRead += req.length; - retries = 0; + if ((flashRead.size - bytesRead) < MAX_FLASH_DATA) { + req.length = flashRead.size - bytesRead; + } else { + req.length = MAX_FLASH_DATA; } - file.close(); - return RETURN_OK; + req.address = flashRead.address + bytesRead; + arc_pack_read_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.address); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkActionReply(); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkFlashActionReply(req.region, req.address, req.length); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + FLASH_READ_DATA_OFFSET), + req.length); + bytesRead += req.length; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performFpgaDownload() { - ReturnValue_t result; - struct DownloadFPGAImageActionRequest req; - uint32_t size = 0; - uint32_t retries = 0; - Timestamp timestamp; - std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName; - std::ofstream file(image, std::ios_base::app | std::ios_base::out); - if(not std::filesystem::exists(image)) { - return FILE_CREATION_FAILED; + ReturnValue_t result; + struct DownloadFPGAImageActionRequest req; + uint32_t size = 0; + uint32_t retries = 0; + Timestamp timestamp; + std::string image = fpgaDownload.path + "/" + timestamp.str() + fpgaDownload.fileName; + std::ofstream file(image, std::ios_base::app | std::ios_base::out); + if (not std::filesystem::exists(image)) { + return FILE_CREATION_FAILED; + } + req.pos = fpgaDownload.startPosition; + while (req.pos < fpgaDownload.length) { + if (terminate) { + return RETURN_OK; } - req.pos = fpgaDownload.startPosition; - while(req.pos < fpgaDownload.length) { - if (terminate) { - return RETURN_OK; - } - if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) { - req.length = FpgaDownload::MAX_DATA; - } - else { - req.length = fpgaDownload.length - req.pos; - } - arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size); - result = sendAndRead(size, req.pos); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - result = checkFpgaActionReply(req.pos, req.length); - if (result != RETURN_OK) { - if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { - uartComIF->flushUartRxBuffer(comCookie); - retries++; - continue; - } - file.close(); - return result; - } - file.write(reinterpret_cast(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET), - req.length); - req.pos += req.length; - retries = 0; + if (fpgaDownload.length - req.pos >= FpgaDownload::MAX_DATA) { + req.length = FpgaDownload::MAX_DATA; + } else { + req.length = fpgaDownload.length - req.pos; } - file.close(); - return RETURN_OK; + arc_pack_downloadfpgaimage_action_req(&req, commandBuffer, &size); + result = sendAndRead(size, req.pos); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + result = checkFpgaActionReply(req.pos, req.length); + if (result != RETURN_OK) { + if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { + uartComIF->flushUartRxBuffer(comCookie); + retries++; + continue; + } + file.close(); + return result; + } + file.write(reinterpret_cast(datalinkLayer.getReply() + FpgaDownload::DATA_OFFSET), + req.length); + req.pos += req.length; + retries = 0; + } + file.close(); + return RETURN_OK; } ReturnValue_t StrHelper::performFpgaUpload() { - ReturnValue_t result = RETURN_OK; - uint32_t commandSize = 0; - uint32_t bytesUploaded = 0; - uint32_t fileSize = 0; - struct UploadFPGAImageActionRequest req; - if (not std::filesystem::exists(fpgaUpload.uploadFile)) { - triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); - internalState = InternalState::IDLE; - return RETURN_FAILED; + ReturnValue_t result = RETURN_OK; + uint32_t commandSize = 0; + uint32_t bytesUploaded = 0; + uint32_t fileSize = 0; + struct UploadFPGAImageActionRequest req; + if (not std::filesystem::exists(fpgaUpload.uploadFile)) { + triggerEvent(STR_HELPER_FILE_NOT_EXISTS, static_cast(internalState)); + internalState = InternalState::IDLE; + return RETURN_FAILED; + } + std::ifstream file(flashWrite.fullname, std::ifstream::binary); + file.seekg(0, file.end); + fileSize = file.tellg(); + req.pos = 0; + while (bytesUploaded <= fileSize) { + if (terminate) { + return RETURN_OK; } - std::ifstream file(flashWrite.fullname, std::ifstream::binary); - file.seekg(0, file.end); - fileSize = file.tellg(); - req.pos = 0; - while(bytesUploaded <= fileSize) { - if (terminate) { - return RETURN_OK; - } - if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) { - req.length = FpgaUpload::MAX_DATA; - } - else { - req.length = fileSize - bytesUploaded; - } - file.seekg(bytesUploaded, file.beg); - file.read(reinterpret_cast(req.data), req.length); - arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize); - result = sendAndRead(commandSize, req.pos); - if (result != RETURN_OK) { - return RETURN_FAILED; - } - result = checkFpgaActionReply(req.pos, req.length); - if (result != RETURN_OK) { - return result; - } - bytesUploaded += req.length; + if (fileSize - bytesUploaded > FpgaUpload::MAX_DATA) { + req.length = FpgaUpload::MAX_DATA; + } else { + req.length = fileSize - bytesUploaded; } - return RETURN_OK; + file.seekg(bytesUploaded, file.beg); + file.read(reinterpret_cast(req.data), req.length); + arc_pack_uploadfpgaimage_action_req(&req, commandBuffer, &commandSize); + result = sendAndRead(commandSize, req.pos); + if (result != RETURN_OK) { + return RETURN_FAILED; + } + result = checkFpgaActionReply(req.pos, req.length); + if (result != RETURN_OK) { + return result; + } + bytesUploaded += req.length; + } + return RETURN_OK; } ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { - ReturnValue_t result = RETURN_OK; - ReturnValue_t decResult = RETURN_OK; - size_t receivedDataLen = 0; - uint8_t *receivedData = nullptr; - size_t bytesLeft = 0; - uint32_t missedReplies = 0; - datalinkLayer.encodeFrame(commandBuffer, size); - result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), - datalinkLayer.getEncodedLength()); + ReturnValue_t result = RETURN_OK; + ReturnValue_t decResult = RETURN_OK; + size_t receivedDataLen = 0; + uint8_t* receivedData = nullptr; + size_t bytesLeft = 0; + uint32_t missedReplies = 0; + datalinkLayer.encodeFrame(commandBuffer, size); + result = uartComIF->sendMessage(comCookie, datalinkLayer.getEncodedFrame(), + datalinkLayer.getEncodedLength()); + if (result != RETURN_OK) { + sif::warning << "StrHelper::sendAndRead: Failed to send packet" << std::endl; + triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, parameter); + return RETURN_FAILED; + } + decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; + while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { + result = uartComIF->requestReceiveMessage(comCookie, StarTracker::MAX_FRAME_SIZE * 2 + 2); if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to send packet" << std::endl; - triggerEvent(STR_HELPER_SENDING_PACKET_FAILED, result, parameter); - return RETURN_FAILED; + sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl; + triggerEvent(STR_HELPER_REQUESTING_MSG_FAILED, result, parameter); + return RETURN_FAILED; } - decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; - while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { - 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); - return RETURN_FAILED; - } - result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); - if (result != RETURN_OK) { - sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl; - triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter); - return RETURN_FAILED; - } - if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { - missedReplies++; - continue; - } - else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { - triggerEvent(STR_HELPER_NO_REPLY, parameter); - return RETURN_FAILED; - } - else { - missedReplies = 0; - } - decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); - if (bytesLeft != 0) { - // This should never happen - sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl; - triggerEvent(STR_HELPER_COM_ERROR, result, parameter); - return RETURN_FAILED; - } + result = uartComIF->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); + if (result != RETURN_OK) { + sif::warning << "StrHelper::sendAndRead: Failed to read received message" << std::endl; + triggerEvent(STR_HELPER_READING_REPLY_FAILED, result, parameter); + return RETURN_FAILED; } - if (decResult != RETURN_OK) { - triggerEvent(STR_HELPER_DEC_ERROR, decResult, parameter); - return RETURN_FAILED; + if (receivedDataLen == 0 && missedReplies < MAX_POLLS) { + missedReplies++; + continue; + } else if ((receivedDataLen == 0) && (missedReplies >= MAX_POLLS)) { + triggerEvent(STR_HELPER_NO_REPLY, parameter); + return RETURN_FAILED; + } else { + missedReplies = 0; } - return RETURN_OK; + decResult = datalinkLayer.decodeFrame(receivedData, receivedDataLen, &bytesLeft); + if (bytesLeft != 0) { + // This should never happen + sif::warning << "StrHelper::sendAndRead: Bytes left after decoding" << std::endl; + triggerEvent(STR_HELPER_COM_ERROR, result, parameter); + return RETURN_FAILED; + } + } + if (decResult != RETURN_OK) { + triggerEvent(STR_HELPER_DEC_ERROR, decResult, parameter); + return RETURN_FAILED; + } + return RETURN_OK; } 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; - return INVALID_TYPE_ID; - } - uint8_t status = datalinkLayer.getStatusField(); - if (status != ArcsecDatalinkLayer::STATUS_OK) { - sif::warning << "StrHelper::checkActionReply: Status failure: " - << static_cast(status) << std::endl; - return STATUS_ERROR; - } - return RETURN_OK; + uint8_t type = datalinkLayer.getReplyFrameType(); + if (type != TMTC_ACTIONREPLY) { + sif::warning << "StrHelper::checkActionReply: Received reply with invalid type ID" << std::endl; + return INVALID_TYPE_ID; + } + uint8_t status = datalinkLayer.getStatusField(); + if (status != ArcsecDatalinkLayer::STATUS_OK) { + sif::warning << "StrHelper::checkActionReply: Status failure: " + << static_cast(status) << std::endl; + return STATUS_ERROR; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) { - uint32_t receivedPosition = 0; - std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); - if (receivedPosition != expectedPosition) { - triggerEvent(POSITION_MISMATCH, receivedPosition); - return RETURN_FAILED; - } - return RETURN_OK; + uint32_t receivedPosition = 0; + std::memcpy(&receivedPosition, datalinkLayer.getReply() + POS_OFFSET, sizeof(receivedPosition)); + if (receivedPosition != expectedPosition) { + triggerEvent(POSITION_MISMATCH, receivedPosition); + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_, - uint16_t length_) { - ReturnValue_t result = RETURN_OK; - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* data = datalinkLayer.getReply(); - uint8_t region = *(data + REGION_OFFSET); - uint32_t address; - const uint8_t* addressData = data + ADDRESS_OFFSET; - size_t size = sizeof(address); - result = SerializeAdapter::deSerialize(&address, &addressData, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" - << std::endl; - return result; - } - uint16_t length = 0; - size = sizeof(length); - const uint8_t* lengthData = data + LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&length, lengthData, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed" - << std::endl; - } - if (region != region_) { - return REGION_MISMATCH; - } - if (address != address_) { - return ADDRESS_MISMATCH; - } - if (length != length_) { - return LENGTH_MISMATCH; - } - return RETURN_OK; + uint16_t length_) { + ReturnValue_t result = RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { + return result; + } + const uint8_t* data = datalinkLayer.getReply(); + uint8_t region = *(data + REGION_OFFSET); + uint32_t address; + const uint8_t* addressData = data + ADDRESS_OFFSET; + size_t size = sizeof(address); + result = + SerializeAdapter::deSerialize(&address, &addressData, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed" + << std::endl; + return result; + } + uint16_t length = 0; + size = sizeof(length); + const uint8_t* lengthData = data + LENGTH_OFFSET; + result = + SerializeAdapter::deSerialize(&length, lengthData, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed" + << std::endl; + } + if (region != region_) { + return REGION_MISMATCH; + } + if (address != address_) { + return ADDRESS_MISMATCH; + } + if (length != length_) { + return LENGTH_MISMATCH; + } + return RETURN_OK; } -ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, - uint32_t expectedLength) { - ReturnValue_t result = RETURN_OK; - result = checkActionReply(); - if (result != RETURN_OK) { - return result; - } - 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); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - result = SerializeAdapter::deSerialize(&length, &data, &size, - SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed" - << std::endl; - return result; - } +ReturnValue_t StrHelper::checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength) { + ReturnValue_t result = RETURN_OK; + result = checkActionReply(); + if (result != RETURN_OK) { return result; + } + 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); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of position failed" + << std::endl; + return result; + } + uint32_t length; + size = sizeof(length); + result = SerializeAdapter::deSerialize(&length, &data, &size, SerializeIF::Endianness::LITTLE); + if (result != RETURN_OK) { + sif::warning << "StrHelper::checkFpgaActionReply: Deserialization of length failed" + << std::endl; + return result; + } + return result; } 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 (!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)) { - if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { - sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl; - return SD_NOT_MOUNTED; - } + 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; } - return RETURN_OK; + } 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; + } + } + return RETURN_OK; } diff --git a/bsp_q7s/devices/startracker/StrHelper.h b/bsp_q7s/devices/startracker/StrHelper.h index e140a4d6..c08aaae1 100644 --- a/bsp_q7s/devices/startracker/StrHelper.h +++ b/bsp_q7s/devices/startracker/StrHelper.h @@ -2,396 +2,396 @@ #define BSP_Q7S_DEVICES_STRHELPER_H_ #include + #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/client/generated/actionreq.h" +#include "thirdparty/arcsec_star_tracker/common/generated/tmtcstructs.h" } /** * @brief Helper class for the star tracker handler to accelerate large data transfers. */ -class StrHelper: public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { -public: +class StrHelper : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { + public: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER; + //! [EXPORT] : [COMMENT] Image upload failed + static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Image download failed + static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop + static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Image download was successful + static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash write procedure successfully + static const Event FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] Finished flash read procedure successfully + static const Event FLASH_READ_SUCCESSFUL = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Flash write procedure failed + static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Flash read procedure failed + static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image successful + static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW); + //! [EXPORT] : [COMMENT] Download of FPGA image failed + static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image successful + static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); + //! [EXPORT] : [COMMENT] Upload of FPGA image failed + static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW); + //! [EXPORT] : [COMMENT] Failed to read communication interface reply data + //! P1: Return code of failed communication interface read call + //! P1: Upload/download position for which the read call failed + static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW); + //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence + //! P1: Return code of failed communication interface read call + //! P1: Upload/download position for which the read call failed + static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW); + //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) + //! P1: Position of upload or download packet for which no reply was sent + static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW); + //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred + // P1: Return value of decoding function + // P2: Position of upload/download packet, or address of flash write/read request + static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW); + //! [EXPORT] : [COMMENT] Position mismatch + //! P1: The expected position and thus the position for which the image upload/download failed + static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW); + //! [EXPORT] : [COMMENT] Specified file does not exist + //! P1: Internal state of str helper + 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 + 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 + static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW); - //! [EXPORT] : [COMMENT] Image upload failed - static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(0, severity::LOW); - //! [EXPORT] : [COMMENT] Image download failed - static const Event IMAGE_DOWNLOAD_FAILED = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop - static const Event IMAGE_UPLOAD_SUCCESSFUL = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Image download was successful - static const Event IMAGE_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Finished flash write procedure successfully - static const Event FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] Finished flash read procedure successfully - static const Event FLASH_READ_SUCCESSFUL = MAKE_EVENT(5, severity::LOW); - //! [EXPORT] : [COMMENT] Flash write procedure failed - static const Event FLASH_WRITE_FAILED = MAKE_EVENT(6, severity::LOW); - //! [EXPORT] : [COMMENT] Flash read procedure failed - static const Event FLASH_READ_FAILED = MAKE_EVENT(7, severity::LOW); - //! [EXPORT] : [COMMENT] Download of FPGA image successful - static const Event FPGA_DOWNLOAD_SUCCESSFUL = MAKE_EVENT(8, severity::LOW); - //! [EXPORT] : [COMMENT] Download of FPGA image failed - static const Event FPGA_DOWNLOAD_FAILED = MAKE_EVENT(9, severity::LOW); - //! [EXPORT] : [COMMENT] Upload of FPGA image successful - static const Event FPGA_UPLOAD_SUCCESSFUL = MAKE_EVENT(10, severity::LOW); - //! [EXPORT] : [COMMENT] Upload of FPGA image failed - static const Event FPGA_UPLOAD_FAILED = MAKE_EVENT(11, severity::LOW); - //! [EXPORT] : [COMMENT] Failed to read communication interface reply data - //!P1: Return code of failed communication interface read call - //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW); - //! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence - //!P1: Return code of failed communication interface read call - //!P1: Upload/download position for which the read call failed - static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW); - //! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off) - //!P1: Position of upload or download packet for which no reply was sent - static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW); - //! [EXPORT] : [COMMENT] Error during decoding of received reply occurred - //P1: Return value of decoding function - //P2: Position of upload/download packet, or address of flash write/read request - static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW); - //! [EXPORT] : [COMMENT] Position mismatch - //! P1: The expected position and thus the position for which the image upload/download failed - static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW); - //! [EXPORT] : [COMMENT] Specified file does not exist - //!P1: Internal state of str helper - 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 - 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 - static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW); + StrHelper(object_id_t objectId); + virtual ~StrHelper(); - StrHelper(object_id_t objectId); - virtual ~StrHelper(); + ReturnValue_t initialize() override; + ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t initialize() override; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_); + void setComCookie(CookieIF* comCookie_); - ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_); - void setComCookie(CookieIF* comCookie_); + /** + * @brief Starts sequence to upload image to star tracker + * + * @param uploadImage_ Name including absolute path of the image to upload. Must be previously + * transferred to the OBC with the CFDP protocol. + */ + ReturnValue_t startImageUpload(std::string uploadImage_); - /** - * @brief Starts sequence to upload image to star tracker - * - * @param uploadImage_ Name including absolute path of the image to upload. Must be previously - * transferred to the OBC with the CFDP protocol. - */ - ReturnValue_t startImageUpload(std::string uploadImage_); + /** + * @brief Calling this function initiates the download of an image from the star tracker. + * + * @param path Path where downloaded image will be stored + */ + ReturnValue_t startImageDownload(std::string path); - /** - * @brief Calling this function initiates the download of an image from the star tracker. - * - * @param path Path where downloaded image will be stored - */ - ReturnValue_t startImageDownload(std::string path); + /** + * @brief Starts the flash write procedure + * + * @param fullname Full name including absolute path of file to write to flash + * @param region Region ID of flash region to write to + * @param address Start address of flash write procedure + */ + ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address); - /** - * @brief Starts the flash write procedure - * - * @param fullname Full name including absolute path of file to write to flash - * @param region Region ID of flash region to write to - * @param address Start address of flash write procedure - */ - ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address); + /** + * @brief Starts the flash read procedure + * + * @param path Path where file with read flash data will be created + * @param region Region ID of flash region to read from + * @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); - /** - * @brief Starts the flash read procedure - * - * @param path Path where file with read flash data will be created - * @param region Region ID of flash region to read from - * @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); + /** + * @brief Starts the download of the FPGA image + * + * @param path The path where the file with the downloaded data will be created + * @param startPosition Offset in fpga image to read from + * @param length Number of bytes to dwonload from the FPGA image + * + */ + ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); - /** - * @brief Starts the download of the FPGA image - * - * @param path The path where the file with the downloaded data will be created - * @param startPosition Offset in fpga image to read from - * @param length Number of bytes to dwonload from the FPGA image - * - */ - ReturnValue_t startFpgaDownload(std::string path, uint32_t startPosition, uint32_t length); + /** + * @brief Starts upload of new image to FPGA + * + * @param uploadFile Full name of file containing FPGA image data + */ + ReturnValue_t startFpgaUpload(std::string uploadFile); - /** - * @brief Starts upload of new image to FPGA - * - * @param uploadFile Full name of file containing FPGA image data - */ - ReturnValue_t startFpgaUpload(std::string uploadFile); + /** + * @brief Can be used to interrupt a running data transfer. + */ + void stopProcess(); - /** - * @brief Can be used to interrupt a running data transfer. - */ - void stopProcess(); + /** + * @brief Changes the dafault name of downloaded images + */ + void setDownloadImageName(std::string filename); - /** - * @brief Changes the dafault name of downloaded images - */ - void setDownloadImageName(std::string filename); + /** + * @brief Sets the name of the file which will be created to store the data read from flash + */ + void setFlashReadFilename(std::string filename); - /** - * @brief Sets the name of the file which will be created to store the data read from flash - */ - void setFlashReadFilename(std::string filename); + /** + * @brief Set download FPGA image name + */ + void setDownloadFpgaImage(std::string filename); - /** - * @brief Set download FPGA image name - */ - void setDownloadFpgaImage(std::string filename); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; -private: + //! [EXPORT] : [COMMENT] SD card specified in path string not mounted + static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Specified file does not exist on filesystem + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Specified path does not exist + static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Failed to create download image or read flash file + static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Region in flash write/read reply does not match expected region + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Address in flash write/read reply does not match expected address + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length + static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Status field in reply signals error + static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type) + static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8); - static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER; + // Size of one image part which can be sent per action request + static const size_t SIZE_IMAGE_PART = 1024; - //! [EXPORT] : [COMMENT] SD card specified in path string not mounted - static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Specified file does not exist on filesystem - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Specified path does not exist - static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Failed to create download image or read flash file - static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Region in flash write/read reply does not match expected region - static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xA4); - //! [EXPORT] : [COMMENT] Address in flash write/read reply does not match expected address - static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xA5); - //! [EXPORT] : [COMMENT] Length in flash write/read reply does not match expected length - static const ReturnValue_t LENGTH_MISMATCH = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] Status field in reply signals error - static const ReturnValue_t STATUS_ERROR = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Reply has invalid type ID (should be of action reply type) - static const ReturnValue_t INVALID_TYPE_ID = MAKE_RETURN_CODE(0xA8); + class ImageDownload { + public: + static const uint32_t LAST_POSITION = 4095; + }; - // Size of one image part which can be sent per action request - static const size_t SIZE_IMAGE_PART = 1024; + class FpgaDownload { + public: + static const uint16_t MAX_DATA = 1024; + static const uint8_t DATA_OFFSET = 10; + // Start position of fpga image part to download + uint32_t startPosition = 0; + // Length of image part to download + uint32_t length = 0; + // Path where downloaded FPGA image will be stored + std::string path; + // Name of file containing downloaded FPGA image + std::string fileName = "fpgaimage.bin"; + }; + FpgaDownload fpgaDownload; - class ImageDownload { - public: - static const uint32_t LAST_POSITION = 4095; - }; + class FpgaUpload { + public: + static const uint32_t MAX_DATA = 1024; + // Full name of file to upload + std::string uploadFile; + }; + FpgaUpload fpgaUpload; - class FpgaDownload { - public: - static const uint16_t MAX_DATA = 1024; - static const uint8_t DATA_OFFSET = 10; - // Start position of fpga image part to download - uint32_t startPosition = 0; - // Length of image part to download - uint32_t length = 0; - // Path where downloaded FPGA image will be stored - std::string path; - // Name of file containing downloaded FPGA image - std::string fileName = "fpgaimage.bin"; - }; - FpgaDownload fpgaDownload; + static const uint32_t MAX_POLLS = 10000; - class FpgaUpload { - public: - static const uint32_t MAX_DATA = 1024; - // Full name of file to upload - std::string uploadFile; - }; - FpgaUpload fpgaUpload; + static const uint8_t ACTION_DATA_OFFSET = 2; + static const uint8_t POS_OFFSET = 2; + static const uint8_t IMAGE_DATA_OFFSET = 5; + static const uint8_t FLASH_READ_DATA_OFFSET = 8; + static const uint8_t REGION_OFFSET = 2; + static const uint8_t ADDRESS_OFFSET = 3; + static const uint8_t LENGTH_OFFSET = 7; + static const size_t IMAGE_DATA_SIZE = 1024; + static const size_t MAX_FLASH_DATA = 1024; + static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; - static const uint32_t MAX_POLLS = 10000; + enum class InternalState { + IDLE, + UPLOAD_IMAGE, + DOWNLOAD_IMAGE, + FLASH_WRITE, + FLASH_READ, + DOWNLOAD_FPGA_IMAGE, + UPLOAD_FPGA_IMAGE + }; - static const uint8_t ACTION_DATA_OFFSET = 2; - static const uint8_t POS_OFFSET = 2; - static const uint8_t IMAGE_DATA_OFFSET = 5; - static const uint8_t FLASH_READ_DATA_OFFSET = 8; - static const uint8_t REGION_OFFSET = 2; - static const uint8_t ADDRESS_OFFSET = 3; - static const uint8_t LENGTH_OFFSET = 7; - static const size_t IMAGE_DATA_SIZE = 1024; - static const size_t MAX_FLASH_DATA = 1024; - static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; + InternalState internalState = InternalState::IDLE; - enum class InternalState { - IDLE, - UPLOAD_IMAGE, - DOWNLOAD_IMAGE, - FLASH_WRITE, - FLASH_READ, - DOWNLOAD_FPGA_IMAGE, - UPLOAD_FPGA_IMAGE - }; + ArcsecDatalinkLayer datalinkLayer; - InternalState internalState = InternalState::IDLE; + BinarySemaphore semaphore; - ArcsecDatalinkLayer datalinkLayer; + class UploadImage { + public: + // Name including absolute path of image to upload + std::string uploadFile; + }; + UploadImage uploadImage; - BinarySemaphore semaphore; + class DownloadImage { + public: + // Path where the downloaded image will be stored + std::string path; + // Default name of downloaded image, can be changed via command + std::string filename = "image.bin"; + }; + DownloadImage downloadImage; - class UploadImage { - public: - // Name including absolute path of image to upload - std::string uploadFile; - }; - UploadImage uploadImage; + class FlashWrite { + public: + // File which contains data to write when executing the flash write command + std::string fullname; + // Will be set with the flash write command + uint8_t region = 0; + // Will be set with the flash write command and specifies the start address where to write the + // flash data to + uint32_t address = 0; + }; + FlashWrite flashWrite; - class DownloadImage { - public: - // Path where the downloaded image will be stored - std::string path; - // Default name of downloaded image, can be changed via command - std::string filename = "image.bin"; - }; - DownloadImage downloadImage; + class FlashRead { + public: + // Path where the file containing the read data will be stored + std::string path = ""; + // Default name of file containing the data read from flash, can be changed via command + std::string filename = "flashread.bin"; + // Will be set with the flash read command + uint8_t region = 0; + // Will be set with the flash read command and specifies the start address of the flash section + // to read + uint32_t address = 0; + // Number of bytes to read from flash + uint32_t size = 0; + }; + FlashRead flashRead; - class FlashWrite { - public: - // File which contains data to write when executing the flash write command - std::string fullname; - // Will be set with the flash write command - uint8_t region = 0; - // Will be set with the flash write command and specifies the start address where to write the - // flash data to - uint32_t address = 0; - }; - FlashWrite flashWrite; + SdCardManager* sdcMan = nullptr; - class FlashRead { - public: - // Path where the file containing the read data will be stored - std::string path = ""; - // Default name of file containing the data read from flash, can be changed via command - std::string filename = "flashread.bin"; - // Will be set with the flash read command - uint8_t region = 0; - // Will be set with the flash read command and specifies the start address of the flash section - // to read - uint32_t address = 0; - // Number of bytes to read from flash - uint32_t size = 0; - }; - FlashRead flashRead; + uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; - SdCardManager* sdcMan = nullptr; + bool terminate = false; - uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE]; + /** + * UART communication object responsible for low level access of star tracker + * Must be set by star tracker handler + */ + UartComIF* uartComIF = nullptr; + // Communication cookie. Must be set by the star tracker handler + CookieIF* comCookie = nullptr; - bool terminate = false; + // Queue id of raw data receiver + MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE; - /** - * UART communication object responsible for low level access of star tracker - * Must be set by star tracker handler - */ - UartComIF* uartComIF = nullptr; - // Communication cookie. Must be set by the star tracker handler - CookieIF* comCookie = nullptr; + /** + * @brief Performs image uploading + */ + ReturnValue_t performImageUpload(); - // Queue id of raw data receiver - MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE; + /** + * @brief Performs download of last taken image from the star tracker. + * + * @details Download is split over multiple packets transporting each a maximum of 1024 bytes. + * In case the download of one position fails, the same packet will be again + * requested. If the download of the packet fails CONFIG_MAX_DOWNLOAD_RETRIES times, + * the download will be stopped. + */ + ReturnValue_t performImageDownload(); - /** - * @brief Performs image uploading - */ - ReturnValue_t performImageUpload(); + /** + * @brief Handles flash write procedure + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t performFlashWrite(); - /** - * @brief Performs download of last taken image from the star tracker. - * - * @details Download is split over multiple packets transporting each a maximum of 1024 bytes. - * In case the download of one position fails, the same packet will be again - * requested. If the download of the packet fails CONFIG_MAX_DOWNLOAD_RETRIES times, - * the download will be stopped. - */ - ReturnValue_t performImageDownload(); + /** + * @brief Sends a sequence of commands to the star tracker to read larger parts from the + * flash memory. + */ + ReturnValue_t performFlashRead(); - /** - * @brief Handles flash write procedure - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t performFlashWrite(); + /** + * @brief Performs the download of the FPGA image which requires to be slip over multiple + * action requests. + */ + ReturnValue_t performFpgaDownload(); - /** - * @brief Sends a sequence of commands to the star tracker to read larger parts from the - * flash memory. - */ - ReturnValue_t performFlashRead(); + /** + * @brief Performs upload of new FPGA image. Upload sequence split over multiple commands + * because one command can only transport 1024 bytes of image data. + */ + ReturnValue_t performFpgaUpload(); - /** - * @brief Performs the download of the FPGA image which requires to be slip over multiple - * action requests. - */ - ReturnValue_t performFpgaDownload(); + /** + * @brief Sends packet to the star tracker and reads reply by using the communication + * interface + * + * @param size Size of data beforehand written to the commandBuffer + * @param parameter Parameter 2 of trigger event function + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t sendAndRead(size_t size, uint32_t parameter); - /** - * @brief Performs upload of new FPGA image. Upload sequence split over multiple commands - * because one command can only transport 1024 bytes of image data. - */ - ReturnValue_t performFpgaUpload(); + /** + * @brief Checks the header (type id and status fields) of the action reply + * + * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED + */ + ReturnValue_t checkActionReply(); - /** - * @brief Sends packet to the star tracker and reads reply by using the communication - * interface - * - * @param size Size of data beforehand written to the commandBuffer - * @param parameter Parameter 2 of trigger event function - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t sendAndRead(size_t size, uint32_t parameter); + /** + * @brief Checks the position field in a star tracker upload/download reply. + * + * @param expectedPosition Value of expected position + * + * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED + */ + ReturnValue_t checkReplyPosition(uint32_t expectedPosition); - /** - * @brief Checks the header (type id and status fields) of the action reply - * - * @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED - */ - ReturnValue_t checkActionReply(); + /** + * @brief Checks the region, address and length value of a flash write or read reply. + * + * @return RETURN_OK if values match expected values, otherwise appropriate error return + * value. + */ + ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); - /** - * @brief Checks the position field in a star tracker upload/download reply. - * - * @param expectedPosition Value of expected position - * - * @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED - */ - ReturnValue_t checkReplyPosition(uint32_t expectedPosition); + /** + * @brief Checks the reply to the fpga download and upload request + * + * @param expectedPosition The expected position value in the reply + * @param expectedLength The expected length field in the reply + */ + ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength); - /** - * @brief Checks the region, address and length value of a flash write or read reply. - * - * @return RETURN_OK if values match expected values, otherwise appropriate error return - * value. - */ - ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_); - - /** - * @brief Checks the reply to the fpga download and upload request - * - * @param expectedPosition The expected position value in the reply - * @param expectedLength The expected length field in the reply - */ - ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength); - - /** - * @brief Checks if a path points to an sd card and whether the SD card is monuted. - * - * @return SD_NOT_MOUNTED id SD card is not mounted, otherwise RETURN_OK - */ - ReturnValue_t checkPath(std::string name); + /** + * @brief Checks if a path points to an sd card and whether the SD card is monuted. + * + * @return SD_NOT_MOUNTED id SD card is not mounted, otherwise RETURN_OK + */ + ReturnValue_t checkPath(std::string name); }; #endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */ diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 2cbf3320..e3033b7d 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -1,512 +1,504 @@ #include "gpioCallbacks.h" -#include "busConf.h" + #include - -#include -#include #include +#include +#include +#include "busConf.h" namespace gpioCallbacks { GpioIF* gpioComInterface; void initSpiCsDecoder(GpioIF* gpioComIF) { + ReturnValue_t result; - ReturnValue_t result; + if (gpioComIF == nullptr) { + sif::debug << "initSpiCsDecoder: Invalid gpioComIF" << std::endl; + return; + } - if (gpioComIF == nullptr) { - sif::debug << "initSpiCsDecoder: Invalid gpioComIF" << std::endl; - return; - } + gpioComInterface = gpioComIF; - gpioComInterface = gpioComIF; + GpioCookie* spiMuxGpios = new GpioCookie; - GpioCookie* spiMuxGpios = new GpioCookie; + GpiodRegularByLineName* spiMuxBit = nullptr; + /** Setting mux bit 1 to low will disable IC21 on the interface board */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + gpio::DIR_OUT, gpio::HIGH); + 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::DIR_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::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); - GpiodRegularByLineName* spiMuxBit = nullptr; - /** Setting mux bit 1 to low will disable IC21 on the interface board */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", - gpio::DIR_OUT, gpio::HIGH); - 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::DIR_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::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_3, spiMuxBit); + // spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_1_PIN, "SPI Mux Bit 1", + // 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_1_PIN, "SPI Mux Bit 1", -// 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); + /** The following gpios can take arbitrary initial values */ + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); + spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", + gpio::DIR_OUT, gpio::LOW); + spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); + 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); + spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); - /** The following gpios can take arbitrary initial values */ - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_4_PIN, "SPI Mux Bit 4", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_4, spiMuxBit); - spiMuxBit = new GpiodRegularByLineName(q7s::gpioNames::SPI_MUX_BIT_5_PIN, "SPI Mux Bit 5", - gpio::DIR_OUT, gpio::LOW); - spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit); - 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); - spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); - - result = gpioComInterface->addGpios(spiMuxGpios); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl; - return; - } + result = gpioComInterface->addGpios(spiMuxGpios); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl; + return; + } } void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value, - void* args) { + void* args) { + if (gpioComInterface == nullptr) { + sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder " + << "to specify gpioComIF" << std::endl; + return; + } - if (gpioComInterface == nullptr) { - sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder " - << "to specify gpioComIF" << std::endl; - return; - } + /* Reading is not supported by the callback function */ + if (gpioOp == gpio::GpioOperation::READ) { + return; + } - /* Reading is not supported by the callback function */ - if (gpioOp == gpio::GpioOperation::READ) { - return; + if (value == gpio::HIGH) { + switch (gpioId) { + case (gpioIds::RTD_IC_3): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_4): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_5): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_6): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_7): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_8): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_9): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_10): { + disableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_11): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_12): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_13): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_14): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_15): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_16): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_17): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_18): { + disableDecoderTcsIc2(); + break; + } + case (gpioIds::CS_SUS_1): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_2): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_3): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_4): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_5): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_6): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_7): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_8): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_9): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_10): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_11): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_12): { + disableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_13): { + disableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_RW1): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW2): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW3): { + disableRwDecoder(); + break; + } + case (gpioIds::CS_RW4): { + disableRwDecoder(); + break; + } + default: + sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; } - - if (value == gpio::HIGH) { - switch (gpioId) { - case(gpioIds::RTD_IC_3): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_4): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_5): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_6): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_7): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_8): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_9): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_10): { - disableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_11): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_12): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_13): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_14): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_15): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_16): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_17): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_18): { - disableDecoderTcsIc2(); - break; - } - case(gpioIds::CS_SUS_1): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_2): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_3): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_4): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_5): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_6): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_7): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_8): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_9): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_10): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_11): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_12): { - disableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_13): { - disableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_RW1): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW2): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW3): { - disableRwDecoder(); - break; - } - case(gpioIds::CS_RW4): { - disableRwDecoder(); - break; - } - default: - sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; - } - } - else if (value == gpio::LOW) { - switch (gpioId) { - case(gpioIds::RTD_IC_3): { - selectY7(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_4): { - selectY6(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_5): { - selectY5(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_6): { - selectY4(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_7): { - selectY3(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_8): { - selectY2(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_9): { - selectY1(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_10): { - selectY0(); - enableDecoderTcsIc1(); - break; - } - case(gpioIds::RTD_IC_11): { - selectY7(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_12): { - selectY6(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_13): { - selectY5(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_14): { - selectY4(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_15): { - selectY3(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_16): { - selectY2(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_17): { - selectY1(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::RTD_IC_18): { - selectY0(); - enableDecoderTcsIc2(); - break; - } - case(gpioIds::CS_SUS_1): { - selectY0(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_2): { - selectY1(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_3): { - selectY0(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_4): { - selectY1(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_5): { - selectY2(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_6): { - selectY2(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_7): { - selectY3(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_8): { - selectY3(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_9): { - selectY4(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_10): { - selectY5(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_SUS_11): { - selectY4(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_12): { - selectY5(); - enableDecoderInterfaceBoardIc2(); - break; - } - case(gpioIds::CS_SUS_13): { - selectY6(); - enableDecoderInterfaceBoardIc1(); - break; - } - case(gpioIds::CS_RW1): { - selectY0(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW2): { - selectY1(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW3): { - selectY2(); - enableRwDecoder(); - break; - } - case(gpioIds::CS_RW4): { - selectY3(); - enableRwDecoder(); - break; - } - default: - sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; - } - } - else { - sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl; + } else if (value == gpio::LOW) { + switch (gpioId) { + case (gpioIds::RTD_IC_3): { + selectY7(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_4): { + selectY6(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_5): { + selectY5(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_6): { + selectY4(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_7): { + selectY3(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_8): { + selectY2(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_9): { + selectY1(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_10): { + selectY0(); + enableDecoderTcsIc1(); + break; + } + case (gpioIds::RTD_IC_11): { + selectY7(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_12): { + selectY6(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_13): { + selectY5(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_14): { + selectY4(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_15): { + selectY3(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_16): { + selectY2(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_17): { + selectY1(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::RTD_IC_18): { + selectY0(); + enableDecoderTcsIc2(); + break; + } + case (gpioIds::CS_SUS_1): { + selectY0(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_2): { + selectY1(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_3): { + selectY0(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_4): { + selectY1(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_5): { + selectY2(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_6): { + selectY2(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_7): { + selectY3(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_8): { + selectY3(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_9): { + selectY4(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_10): { + selectY5(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_SUS_11): { + selectY4(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_12): { + selectY5(); + enableDecoderInterfaceBoardIc2(); + break; + } + case (gpioIds::CS_SUS_13): { + selectY6(); + enableDecoderInterfaceBoardIc1(); + break; + } + case (gpioIds::CS_RW1): { + selectY0(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW2): { + selectY1(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW3): { + selectY2(); + enableRwDecoder(); + break; + } + case (gpioIds::CS_RW4): { + selectY3(); + enableRwDecoder(); + break; + } + default: + sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; } + } else { + sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl; + } } void enableDecoderTcsIc1() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void enableDecoderTcsIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } void enableDecoderInterfaceBoardIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void enableDecoderInterfaceBoardIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); } void disableDecoderTcsIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void disableDecoderTcsIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); } void disableDecoderInterfaceBoardIc1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); } void disableDecoderInterfaceBoardIc2() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_2); + 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); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY1() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY2() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY3() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_6); } void selectY4() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY5() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY6() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void selectY7() { - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); - gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_4); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_5); + gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_6); } void disableAllDecoder() { - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); - gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); - gpioComInterface->pullLow(gpioIds::EN_RW_CS); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::EN_RW_CS); } -} +} // namespace gpioCallbacks diff --git a/bsp_q7s/gpio/gpioCallbacks.h b/bsp_q7s/gpio/gpioCallbacks.h index 18adb52b..6b4e99bf 100644 --- a/bsp_q7s/gpio/gpioCallbacks.h +++ b/bsp_q7s/gpio/gpioCallbacks.h @@ -1,74 +1,73 @@ #ifndef LINUX_GPIO_GPIOCALLBACKS_H_ #define LINUX_GPIO_GPIOCALLBACKS_H_ -#include #include - +#include namespace gpioCallbacks { - /** - * @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on - * the TCS Board and the interface board. - */ - void initSpiCsDecoder(GpioIF* gpioComIF); +/** + * @brief This function initializes the GPIOs used to control the SN74LVC138APWR decoders on + * the TCS Board and the interface board. + */ +void initSpiCsDecoder(GpioIF* gpioComIF); - /** - * @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); +/** + * @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); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the TCS board which is named to IC1 in the schematic. - */ - void enableDecoderTcsIc1(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the TCS board which is named to IC1 in the schematic. + */ +void enableDecoderTcsIc1(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the TCS board which is named to IC2 in the schematic. - */ - void enableDecoderTcsIc2(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the TCS board which is named to IC2 in the schematic. + */ +void enableDecoderTcsIc2(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the inteface board board which is named to IC21 in the schematic. - */ - void enableDecoderInterfaceBoardIc1(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the inteface board board which is named to IC21 in the schematic. + */ +void enableDecoderInterfaceBoardIc1(); - /** - * @brief This function sets mux bits 1-3 to a state which will only enable the decoder - * on the inteface board board which is named to IC22 in the schematic. - */ - void enableDecoderInterfaceBoardIc2(); +/** + * @brief This function sets mux bits 1-3 to a state which will only enable the decoder + * on the inteface board board which is named to IC22 in the schematic. + */ +void enableDecoderInterfaceBoardIc2(); - void disableDecoderTcsIc1(); - void disableDecoderTcsIc2(); - void disableDecoderInterfaceBoardIc1(); - void disableDecoderInterfaceBoardIc2(); +void disableDecoderTcsIc1(); +void disableDecoderTcsIc2(); +void disableDecoderInterfaceBoardIc1(); +void disableDecoderInterfaceBoardIc2(); - /** - * @brief Enables the reaction wheel chip select decoder (IC3). - */ - void enableRwDecoder(); - void disableRwDecoder(); +/** + * @brief Enables the reaction wheel chip select decoder (IC3). + */ +void enableRwDecoder(); +void disableRwDecoder(); - /** - * @brief This function disables all decoder. - */ - void disableAllDecoder(); +/** + * @brief This function disables all decoder. + */ +void disableAllDecoder(); - /** The following functions enable the appropriate channel of the currently enabled decoder */ - void selectY0(); - void selectY1(); - void selectY2(); - void selectY3(); - void selectY4(); - void selectY5(); - void selectY6(); - void selectY7(); -} +/** The following functions enable the appropriate channel of the currently enabled decoder */ +void selectY0(); +void selectY1(); +void selectY2(); +void selectY3(); +void selectY4(); +void selectY5(); +void selectY6(); +void selectY7(); +} // namespace gpioCallbacks #endif /* LINUX_GPIO_GPIOCALLBACKS_H_ */ diff --git a/bsp_q7s/main.cpp b/bsp_q7s/main.cpp index 9ce0dca2..dfcaebf0 100644 --- a/bsp_q7s/main.cpp +++ b/bsp_q7s/main.cpp @@ -12,12 +12,11 @@ * @brief This is the main program for the target hardware. * @return */ -int main(void) -{ - using namespace std; +int main(void) { + using namespace std; #if Q7S_SIMPLE_MODE == 0 - return obsw::obsw(); + return obsw::obsw(); #else - return simple::simple(); + return simple::simple(); #endif } diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index caad94a6..8b5f85c2 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -1,257 +1,241 @@ #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 -#include #include +#include -FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): - SystemObject(fileSystemHandler) { - mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); +#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) { - // Restart OBSW, hints at a memory leak - 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(); - } + while (true) { + try { + fileSystemHandlerLoop(); + } catch (std::bad_alloc& e) { + // Restart OBSW, hints at a memory leak + 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(); } + } } - void FileSystemHandler::fileSystemHandlerLoop() { - CommandMessage filemsg; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while(true) { - if(opCounter % 5 == 0) { - if(coreCtrl->sdInitFinished()) { - fileSystemCheckup(); - } - } - result = mq->receiveMessage(&filemsg); - if(result == MessageQueueIF::EMPTY) { - break; - } - else if(result != HasReturnvaluesIF::RETURN_FAILED) { - sif::warning << "FileSystemHandler::performOperation: Message reception failed!" - << std::endl; - break; - } - Command_t command = filemsg.getCommand(); - switch(command) { - case(GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { - break; - } - case(GenericFileSystemMessage::CMD_CREATE_FILE): { - break; - } - } - opCounter++; + CommandMessage filemsg; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + while (true) { + if (opCounter % 5 == 0) { + if (coreCtrl->sdInitFinished()) { + fileSystemCheckup(); + } + } + result = mq->receiveMessage(&filemsg); + if (result == MessageQueueIF::EMPTY) { + break; + } else if (result != HasReturnvaluesIF::RETURN_FAILED) { + sif::warning << "FileSystemHandler::performOperation: Message reception failed!" << std::endl; + break; + } + Command_t command = filemsg.getCommand(); + switch (command) { + case (GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { + break; + } + case (GenericFileSystemMessage::CMD_CREATE_FILE): { + break; + } } - - // This task will have a low priority and will run permanently in the background - // so we will just run in a permanent loop here and check file system - // messages permanently opCounter++; - TaskFactory::instance()->delayTask(1000); + } + + // This task will have a low priority and will run permanently in the background + // so we will just run in a permanent loop here and check file system + // messages permanently + opCounter++; + TaskFactory::instance()->delayTask(1000); } void FileSystemHandler::fileSystemCheckup() { - SdCardManager::SdStatePair statusPair; - sdcMan->getSdCardActiveStatus(statusPair); - sd::SdCard preferredSdCard; - sdcMan->getPreferredSdCard(preferredSdCard); - if((preferredSdCard == sd::SdCard::SLOT_0) and - (statusPair.first == sd::SdState::MOUNTED)) { - currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + SdCardManager::SdStatePair statusPair; + sdcMan->getSdCardActiveStatus(statusPair); + sd::SdCard preferredSdCard; + sdcMan->getPreferredSdCard(preferredSdCard); + 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 + (statusPair.second == sd::SdState::MOUNTED)) { + currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; + } else { + std::string sdString; + if (preferredSdCard == sd::SdCard::SLOT_0) { + sdString = "0"; + } else { + sdString = "1"; } - else if((preferredSdCard == sd::SdCard::SLOT_1) and - (statusPair.second == sd::SdState::MOUNTED)) { - currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; - } - else { - std::string sdString; - if(preferredSdCard == sd::SdCard::SLOT_0) { - sdString = "0"; - } - 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; - // This function will appear to fix the inconsistent state - ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Oh no. - triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); - sif::error << "FileSystemHandler::fileSystemCheckup: Sanitization failed" << std::endl; - } + 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; + // This function will appear to fix the inconsistent state + ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Oh no. + triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); + sif::error << "FileSystemHandler::fileSystemCheckup: Sanitization failed" << std::endl; } + } } -MessageQueueId_t FileSystemHandler::getCommandQueue() const { - return mq->getId(); -} +MessageQueueId_t FileSystemHandler::getCommandQueue() const { return mq->getId(); } ReturnValue_t FileSystemHandler::initialize() { - coreCtrl = ObjectManager::instance()->get(objects::CORE_CONTROLLER); - if(coreCtrl == nullptr) { - sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle" << - std::endl; - } - sdcMan = SdCardManager::instance(); - sd::SdCard preferredSdCard; - ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - if(preferredSdCard == sd::SdCard::SLOT_0) { - currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; - } - else if(preferredSdCard == sd::SdCard::SLOT_1) { - currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; - } - return HasReturnvaluesIF::RETURN_OK; + coreCtrl = ObjectManager::instance()->get(objects::CORE_CONTROLLER); + if (coreCtrl == nullptr) { + sif::error << "FileSystemHandler::initialize: Could not retrieve core controller handle" + << std::endl; + } + sdcMan = SdCardManager::instance(); + sd::SdCard preferredSdCard; + ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (preferredSdCard == sd::SdCard::SLOT_0) { + currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + } 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, - uint16_t packetNumber, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / filename; - if(not std::filesystem::exists(path)) { - return FILE_DOES_NOT_EXIST; - } - std::ofstream file(path, std::ios_base::app|std::ios_base::out); - file.write(reinterpret_cast(data), size); - if(not file.good()) { - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -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; - } - std::ofstream file(path); - file.write(reinterpret_cast(data), size); - if(not file.good()) { - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -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; - } - int result = std::remove(path.c_str()); - if(result != 0) { - sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl; - return GENERIC_FILE_ERROR; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t FileSystemHandler:: createDirectory(const char* repositoryPath, const char* dirname, - bool createParentDirs, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / dirname; - if(std::filesystem::exists(path)) { - return DIRECTORY_ALREADY_EXISTS; - } - if(std::filesystem::create_directory(path)) { - return HasReturnvaluesIF::RETURN_OK; - } - sif::warning << "Creating directory " << path << " failed" << std::endl; +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)) { + return FILE_DOES_NOT_EXIST; + } + std::ofstream file(path, std::ios_base::app | std::ios_base::out); + file.write(reinterpret_cast(data), size); + if (not file.good()) { return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +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; + } + std::ofstream file(path); + file.write(reinterpret_cast(data), size); + if (not file.good()) { + return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +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; + } + int result = std::remove(path.c_str()); + if (result != 0) { + sif::warning << "FileSystemHandler::deleteFile: Failed with code " << result << std::endl; + return GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / dirname; + if (std::filesystem::exists(path)) { + return DIRECTORY_ALREADY_EXISTS; + } + if (std::filesystem::create_directory(path)) { + return HasReturnvaluesIF::RETURN_OK; + } + sif::warning << "Creating directory " << path << " failed" << std::endl; + return GENERIC_FILE_ERROR; } ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, const char* dirname, - bool deleteRecurively, FileSystemArgsIF* args) { - auto path = getInitPath(args) / repositoryPath / dirname; - if(not std::filesystem::exists(path)) { - return DIRECTORY_DOES_NOT_EXIST; + bool deleteRecurively, FileSystemArgsIF* args) { + auto path = getInitPath(args) / repositoryPath / dirname; + if (not std::filesystem::exists(path)) { + return DIRECTORY_DOES_NOT_EXIST; + } + std::error_code err; + if (not deleteRecurively) { + if (std::filesystem::remove(path, err)) { + return HasReturnvaluesIF::RETURN_OK; + } 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; + if (err.value() == ENOTEMPTY) { + return DIRECTORY_NOT_EMPTY; + } else { + return GENERIC_FILE_ERROR; + } } - std::error_code err; - if(not deleteRecurively) { - if(std::filesystem::remove(path, err)) { - return HasReturnvaluesIF::RETURN_OK; - } - 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; - if(err.value() == ENOTEMPTY) { - return DIRECTORY_NOT_EMPTY; - } - else { - return GENERIC_FILE_ERROR; - } + } else { + if (std::filesystem::remove_all(path, err)) { + return HasReturnvaluesIF::RETURN_OK; + } else { + sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " + "code " + << err.value() << ": " << strerror(err.value()) << std::endl; + // Check error code + if (err.value() == ENOTEMPTY) { + return DIRECTORY_NOT_EMPTY; + } else { + return GENERIC_FILE_ERROR; + } + } + } - } - } - else { - if(std::filesystem::remove_all(path, err)) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - sif::warning << "FileSystemHandler::removeDirectory: Deleting directory failed with " - "code " << err.value() << ": " << strerror(err.value()) << std::endl; - // Check error code - if(err.value() == ENOTEMPTY) { - return DIRECTORY_NOT_EMPTY; - } - else { - return GENERIC_FILE_ERROR; - } - } - } - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::renameFile(const char *repositoryPath, const char *oldFilename, - const char *newFilename, FileSystemArgsIF *args) { - auto basepath = getInitPath(args) / repositoryPath; - std::filesystem::rename(basepath / oldFilename, basepath / newFilename); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t FileSystemHandler::renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args) { + auto basepath = getInitPath(args) / repositoryPath; + std::filesystem::rename(basepath / oldFilename, basepath / newFilename); + return HasReturnvaluesIF::RETURN_OK; } -void FileSystemHandler::parseCfg(FsCommandCfg *cfg, bool& useMountPrefix) { - if(cfg != nullptr) { - useMountPrefix = cfg->useMountPrefix; - } +void FileSystemHandler::parseCfg(FsCommandCfg* cfg, bool& useMountPrefix) { + if (cfg != nullptr) { + useMountPrefix = cfg->useMountPrefix; + } } std::filesystem::path FileSystemHandler::getInitPath(FileSystemArgsIF* args) { - bool useMountPrefix = true; - parseCfg(reinterpret_cast(args), useMountPrefix); - std::string path; - if(useMountPrefix) { - path = currentMountPrefix; - } - return std::filesystem::path(path); + bool useMountPrefix = true; + parseCfg(reinterpret_cast(args), useMountPrefix); + std::string path; + if (useMountPrefix) { + path = currentMountPrefix; + } + return std::filesystem::path(path); } diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 35a0f533..6973c3c8 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -1,71 +1,67 @@ #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 #include +#include + +#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 { -public: - struct FsCommandCfg: public FileSystemArgsIF { - // Can be used to automatically use mount prefix of active SD card. - // Otherwise, the operator has to specify the full path to the mounted SD card as well. - bool useMountPrefix = false; - }; +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. + // Otherwise, the operator has to specify the full path to the mounted SD card as well. + bool useMountPrefix = false; + }; - FileSystemHandler(object_id_t fileSystemHandler); - virtual~ FileSystemHandler(); + FileSystemHandler(object_id_t fileSystemHandler); + virtual ~FileSystemHandler(); - ReturnValue_t performOperation(uint8_t) override; + ReturnValue_t performOperation(uint8_t) override; - ReturnValue_t initialize() override; + ReturnValue_t initialize() override; - /** - * Function to get the MessageQueueId_t of the implementing object - * @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 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; - ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, - const char* newFilename, FileSystemArgsIF* args = nullptr) override; + /** + * Function to get the MessageQueueId_t of the implementing object + * @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 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; + ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args = nullptr) override; -private: - CoreController* coreCtrl = nullptr; - MessageQueueIF* mq = nullptr; - std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; - static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; + private: + CoreController* coreCtrl = nullptr; + MessageQueueIF* mq = nullptr; + std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; - SdCardManager* sdcMan = nullptr; - uint8_t opCounter = 0; + SdCardManager* sdcMan = nullptr; + uint8_t opCounter = 0; - void fileSystemHandlerLoop(); - void fileSystemCheckup(); - std::filesystem::path getInitPath(FileSystemArgsIF* args); - void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix); + void fileSystemHandlerLoop(); + void fileSystemCheckup(); + std::filesystem::path getInitPath(FileSystemArgsIF* args); + void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix); }; - - #endif /* BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ */ diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 8a3d11f2..3647ff7b 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -1,487 +1,462 @@ #include "SdCardManager.h" -#include "scratchApi.h" - -#include "linux/utility/utility.h" - -#include "fsfw/ipc/MutexFactory.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include +#include +#include #include #include -#include -#include + +#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) { - factoryInstance = new SdCardManager(); - } + if (factoryInstance == nullptr) { + factoryInstance = new SdCardManager(); + } } SdCardManager* SdCardManager::instance() { - SdCardManager::create(); - return SdCardManager::factoryInstance; + SdCardManager::create(); + return SdCardManager::factoryInstance; } ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard, - SdStatePair* statusPair) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(doMountSdCard) { - if(not blocking) { - sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is" - " not configured for blocking operation. " - "Forcing blocking mode.." << std::endl; - blocking = true; - } + SdStatePair* statusPair) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if (doMountSdCard) { + if (not blocking) { + sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is" + " not configured for blocking operation. " + "Forcing blocking mode.." + << std::endl; + blocking = true; } - std::unique_ptr sdStatusPtr; - if(statusPair == nullptr) { - sdStatusPtr = std::make_unique(); - statusPair = sdStatusPtr.get(); - result = getSdCardActiveStatus(*statusPair); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + } + std::unique_ptr sdStatusPtr; + if (statusPair == nullptr) { + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); + result = getSdCardActiveStatus(*statusPair); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + } - // Not allowed, this function turns on one SD card - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + // Not allowed, this function turns on one SD card + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } - sd::SdState currentState; - if(sdCard == sd::SdCard::SLOT_0) { - currentState = statusPair->first; - } - else if(sdCard == sd::SdCard::SLOT_1) { - currentState = statusPair->second; - } - else { - // Should not happen - currentState = sd::SdState::OFF; - } + sd::SdState currentState; + if (sdCard == sd::SdCard::SLOT_0) { + currentState = statusPair->first; + } else if (sdCard == sd::SdCard::SLOT_1) { + currentState = statusPair->second; + } else { + // Should not happen + currentState = sd::SdState::OFF; + } - if(currentState == sd::SdState::ON) { - if(not doMountSdCard) { - return ALREADY_ON; - } - else { - return mountSdCard(sdCard); - } - } - else if(currentState == sd::SdState::MOUNTED) { - result = ALREADY_MOUNTED; - } - else if(currentState == sd::SdState::OFF) { - result = setSdCardState(sdCard, true); - } - else { - result = HasReturnvaluesIF::RETURN_FAILED; + if (currentState == sd::SdState::ON) { + if (not doMountSdCard) { + return ALREADY_ON; + } else { + return mountSdCard(sdCard); } + } else if (currentState == sd::SdState::MOUNTED) { + result = ALREADY_MOUNTED; + } else if (currentState == sd::SdState::OFF) { + result = setSdCardState(sdCard, true); + } else { + result = HasReturnvaluesIF::RETURN_FAILED; + } - if(result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { - return result; - } + if (result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { + return result; + } - return mountSdCard(sdCard); + return mountSdCard(sdCard); } ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard, - SdStatePair* statusPair) { - std::pair active; - ReturnValue_t result = getSdCardActiveStatus(active); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; + SdStatePair* statusPair) { + std::pair active; + ReturnValue_t result = getSdCardActiveStatus(active); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + 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; + blocking = true; } - 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; - blocking = true; - } + } + // Not allowed, this function turns off one SD card + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + if (sdCard == sd::SdCard::SLOT_0) { + if (active.first == sd::SdState::OFF) { + return ALREADY_OFF; } - // Not allowed, this function turns off one SD card - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - if(sdCard == sd::SdCard::SLOT_0) { - if(active.first == sd::SdState::OFF) { - return ALREADY_OFF; - } - } - else if(sdCard == sd::SdCard::SLOT_1) { - if(active.second == sd::SdState::OFF) { - return ALREADY_OFF; - } + } else if (sdCard == sd::SdCard::SLOT_1) { + if (active.second == sd::SdState::OFF) { + return ALREADY_OFF; } + } - if(doUnmountSdCard) { - result = unmountSdCard(sdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + if (doUnmountSdCard) { + result = unmountSdCard(sdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + } - return setSdCardState(sdCard, false); + return setSdCardState(sdCard, false); } ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { - using namespace std; - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - string sdstring = ""; - string statestring = ""; - if(sdCard == sd::SdCard::SLOT_0) { - sdstring = "0"; - } - else if(sdCard == sd::SdCard::SLOT_1) { - sdstring = "1"; - } - if(on) { - currentOp = Operations::SWITCHING_ON; - statestring = "on"; - } - else { - currentOp = Operations::SWITCHING_OFF; - statestring = "off"; - } - ostringstream command; - command << "q7hw sd set " << sdstring << " " << statestring; - cmdExecutor.load(command.str(), blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::setSdCardState"); - } - return result; + using namespace std; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + string sdstring = ""; + string statestring = ""; + if (sdCard == sd::SdCard::SLOT_0) { + sdstring = "0"; + } else if (sdCard == sd::SdCard::SLOT_1) { + sdstring = "1"; + } + if (on) { + currentOp = Operations::SWITCHING_ON; + statestring = "on"; + } else { + currentOp = Operations::SWITCHING_OFF; + statestring = "off"; + } + ostringstream command; + command << "q7hw sd set " << sdstring << " " << statestring; + cmdExecutor.load(command.str(), blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::setSdCardState"); + } + return result; } ReturnValue_t SdCardManager::getSdCardActiveStatus(SdStatePair& active) { - using namespace std; - if(not filesystem::exists(SD_STATE_FILE)) { - return STATUS_FILE_NEXISTS; - } + using namespace std; + if (not filesystem::exists(SD_STATE_FILE)) { + return STATUS_FILE_NEXISTS; + } - // Now the file should exist in any case. Still check whether it exists. - fstream sdStatus(SD_STATE_FILE); - if (not sdStatus.good()) { - return STATUS_FILE_NEXISTS; - } - string line; - uint8_t idx = 0; - sd::SdCard currentSd = sd::SdCard::SLOT_0; - // Process status file line by line - while (std::getline(sdStatus, line)) { - processSdStatusLine(active, line, idx, currentSd); - } - return HasReturnvaluesIF::RETURN_OK; + // Now the file should exist in any case. Still check whether it exists. + fstream sdStatus(SD_STATE_FILE); + if (not sdStatus.good()) { + return STATUS_FILE_NEXISTS; + } + string line; + uint8_t idx = 0; + sd::SdCard currentSd = sd::SdCard::SLOT_0; + // Process status file line by line + while (std::getline(sdStatus, line)) { + processSdStatusLine(active, line, idx, currentSd); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) { - using namespace std; - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::mountSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - string mountDev; - string mountPoint; - if(sdCard == sd::SdCard::SLOT_0) { - mountDev = SD_0_DEV_NAME; - mountPoint = SD_0_MOUNT_POINT; - } - 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; - return MOUNT_ERROR; - } + using namespace std; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::mountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + string mountDev; + string mountPoint; + if (sdCard == sd::SdCard::SLOT_0) { + mountDev = SD_0_DEV_NAME; + mountPoint = SD_0_MOUNT_POINT; + } 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; + return MOUNT_ERROR; + } - if(not blocking) { - currentOp = Operations::MOUNTING; - } - string sdMountCommand = "mount " + mountDev + " " + mountPoint; - cmdExecutor.load(sdMountCommand, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); - } - return result; + if (not blocking) { + currentOp = Operations::MOUNTING; + } + string sdMountCommand = "mount " + mountDev + " " + mountPoint; + cmdExecutor.load(sdMountCommand, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); + } + return result; } ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - using namespace std; - if(sdCard == sd::SdCard::BOTH) { - sif::warning << "SdCardManager::unmountSdCard: API does not allow sd::SdStatus::BOTH" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - string mountPoint; - if(sdCard == sd::SdCard::SLOT_0) { - mountPoint = SD_0_MOUNT_POINT; - } - 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; - return UNMOUNT_ERROR; - } - if(filesystem::is_empty(mountPoint)) { - // The mount point will always exist, but if it is empty, that is strong hint that - // the SD card was not mounted properly. Still proceed with operation. - sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; - } - string sdUnmountCommand = "umount " + mountPoint; - if(not blocking) { - currentOp = Operations::UNMOUNTING; - } - cmdExecutor.load(sdUnmountCommand, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::unmountSdCard"); - } - return result; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + using namespace std; + if (sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::unmountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + string mountPoint; + if (sdCard == sd::SdCard::SLOT_0) { + mountPoint = SD_0_MOUNT_POINT; + } 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; + return UNMOUNT_ERROR; + } + if (filesystem::is_empty(mountPoint)) { + // The mount point will always exist, but if it is empty, that is strong hint that + // the SD card was not mounted properly. Still proceed with operation. + sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; + } + string sdUnmountCommand = "umount " + mountPoint; + if (not blocking) { + currentOp = Operations::UNMOUNTING; + } + cmdExecutor.load(sdUnmountCommand, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::unmountSdCard"); + } + return result; } ReturnValue_t SdCardManager::sanitizeState(SdStatePair* statusPair, sd::SdCard prefSdCard) { - std::unique_ptr sdStatusPtr; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - // Enforce blocking operation for now. Be careful to reset it when returning prematurely! - bool resetNonBlockingState = false; - if(not this->blocking) { - blocking = true; - resetNonBlockingState = true; - } - if(prefSdCard == sd::SdCard::NONE) { - result = getPreferredSdCard(prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) {} - } - if(statusPair == nullptr) { - sdStatusPtr = std::make_unique(); - statusPair = sdStatusPtr.get(); - getSdCardActiveStatus(*statusPair); + std::unique_ptr sdStatusPtr; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + // Enforce blocking operation for now. Be careful to reset it when returning prematurely! + bool resetNonBlockingState = false; + if (not this->blocking) { + blocking = true; + resetNonBlockingState = true; + } + if (prefSdCard == sd::SdCard::NONE) { + result = getPreferredSdCard(prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { } + } + if (statusPair == nullptr) { + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); + getSdCardActiveStatus(*statusPair); + } - if(statusPair->first == sd::SdState::ON) { - result = mountSdCard(prefSdCard); - } + if (statusPair->first == sd::SdState::ON) { + result = mountSdCard(prefSdCard); + } - result = switchOnSdCard(prefSdCard, true, statusPair); - if(resetNonBlockingState) { - blocking = false; - } - return result; + result = switchOnSdCard(prefSdCard, true, statusPair); + if (resetNonBlockingState) { + blocking = false; + } + return result; } void SdCardManager::resetState() { - cmdExecutor.reset(); - currentOp = Operations::IDLE; + cmdExecutor.reset(); + currentOp = Operations::IDLE; } -void SdCardManager::processSdStatusLine(std::pair &active, - std::string& line, uint8_t& idx, sd::SdCard& currentSd) { - using namespace std; - istringstream iss(line); - string word; - bool slotLine = false; - bool mountLine = false; - while(iss >> word) { - if (word == "Slot") { - slotLine = true; - } - if(word == "Mounted") { - mountLine = true; - } - - if(slotLine) { - if (word == "1:") { - currentSd = sd::SdCard::SLOT_1; - } - - if(word == "on") { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::ON; - } - else { - active.second = sd::SdState::ON; - } - } - else if (word == "off") { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::OFF; - } - else { - active.second = sd::SdState::OFF; - } - } - } - - if(mountLine) { - if(currentSd == sd::SdCard::SLOT_0) { - active.first = sd::SdState::MOUNTED; - } - 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; - } +void SdCardManager::processSdStatusLine(std::pair& active, + std::string& line, uint8_t& idx, sd::SdCard& currentSd) { + using namespace std; + istringstream iss(line); + string word; + bool slotLine = false; + bool mountLine = false; + while (iss >> word) { + if (word == "Slot") { + slotLine = true; } - idx++; + if (word == "Mounted") { + mountLine = true; + } + + if (slotLine) { + if (word == "1:") { + currentSd = sd::SdCard::SLOT_1; + } + + if (word == "on") { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::ON; + } else { + active.second = sd::SdState::ON; + } + } else if (word == "off") { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::OFF; + } else { + active.second = sd::SdState::OFF; + } + } + } + + if (mountLine) { + if (currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdState::MOUNTED; + } 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; + } + } + idx++; } ReturnValue_t SdCardManager::getPreferredSdCard(sd::SdCard& sdCard) const { - uint8_t prefSdCard = 0; - ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - sdCard = static_cast(prefSdCard); - return HasReturnvaluesIF::RETURN_OK; + uint8_t prefSdCard = 0; + ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + sdCard = static_cast(prefSdCard); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t SdCardManager::setPreferredSdCard(sd::SdCard sdCard) { - if(sdCard == sd::SdCard::BOTH) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sdCard)); + if (sdCard == sd::SdCard::BOTH) { + return HasReturnvaluesIF::RETURN_FAILED; + } + return scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sdCard)); } ReturnValue_t SdCardManager::updateSdCardStateFile() { - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { - return CommandExecutor::COMMAND_PENDING; - } - // Use q7hw utility and pipe the command output into the state file - std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE); - cmdExecutor.load(updateCmd, blocking, printCmdOutput); - ReturnValue_t result = cmdExecutor.execute(); - if(blocking and result != HasReturnvaluesIF::RETURN_OK) { - utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); - } - return result; + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) { + return CommandExecutor::COMMAND_PENDING; + } + // Use q7hw utility and pipe the command output into the state file + std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE); + cmdExecutor.load(updateCmd, blocking, printCmdOutput); + ReturnValue_t result = cmdExecutor.execute(); + if (blocking and result != HasReturnvaluesIF::RETURN_OK) { + utility::handleSystemError(cmdExecutor.getLastError(), "SdCardManager::mountSdCard"); + } + return result; } std::string SdCardManager::getCurrentMountPrefix(sd::SdCard prefSdCard) { - if(prefSdCard == sd::SdCard::NONE) { - ReturnValue_t result = getPreferredSdCard(prefSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - return SD_0_MOUNT_POINT; - } - } - if(prefSdCard == sd::SdCard::SLOT_0) { - return SD_0_MOUNT_POINT; - } - else { - return SD_1_MOUNT_POINT; + if (prefSdCard == sd::SdCard::NONE) { + ReturnValue_t result = getPreferredSdCard(prefSdCard); + if (result != HasReturnvaluesIF::RETURN_OK) { + return SD_0_MOUNT_POINT; } + } + if (prefSdCard == sd::SdCard::SLOT_0) { + return SD_0_MOUNT_POINT; + } else { + return SD_1_MOUNT_POINT; + } } -SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations ¤tOp) { - CommandExecutor::States state = cmdExecutor.getCurrentState(); - if(state == CommandExecutor::States::IDLE or state == CommandExecutor::States::COMMAND_LOADED) { - return OpStatus::IDLE; - } - currentOp = this->currentOp; - bool bytesRead = false; +SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) { + CommandExecutor::States state = cmdExecutor.getCurrentState(); + if (state == CommandExecutor::States::IDLE or state == CommandExecutor::States::COMMAND_LOADED) { + return OpStatus::IDLE; + } + currentOp = this->currentOp; + bool bytesRead = false; #if OBSW_ENABLE_TIMERS == 1 - Timer timer; - timer.setTimer(100); - uint32_t remainingTimeMs = 0; + Timer timer; + timer.setTimer(100); + uint32_t remainingTimeMs = 0; #endif - while(true) { - ReturnValue_t result = cmdExecutor.check(bytesRead); - // This timer can prevent deadlocks due to missconfigurations + while (true) { + ReturnValue_t result = cmdExecutor.check(bytesRead); + // This timer can prevent deadlocks due to missconfigurations #if OBSW_ENABLE_TIMERS == 1 - timer.getTimer(&remainingTimeMs); - if(remainingTimeMs == 0) { - sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl; - return OpStatus::FAIL; - } -#endif - switch(result) { - case(CommandExecutor::BYTES_READ): { - continue; - } - case(CommandExecutor::EXECUTION_FINISHED): { - return OpStatus::SUCCESS; - } - case(HasReturnvaluesIF::RETURN_OK): { - return OpStatus::ONGOING; - } - case(HasReturnvaluesIF::RETURN_FAILED): { - return OpStatus::FAIL; - } - default: { - sif::warning << "SdCardManager::checkCurrentOp: Unhandled case" << std::endl; - } - } + timer.getTimer(&remainingTimeMs); + if (remainingTimeMs == 0) { + sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl; + return OpStatus::FAIL; } +#endif + switch (result) { + case (CommandExecutor::BYTES_READ): { + continue; + } + case (CommandExecutor::EXECUTION_FINISHED): { + return OpStatus::SUCCESS; + } + case (HasReturnvaluesIF::RETURN_OK): { + return OpStatus::ONGOING; + } + case (HasReturnvaluesIF::RETURN_FAILED): { + return OpStatus::FAIL; + } + default: { + sif::warning << "SdCardManager::checkCurrentOp: Unhandled case" << std::endl; + } + } + } } -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; - ReturnValue_t result = this->getSdCardActiveStatus(active); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; - return false; - } - if (sdCard == sd::SLOT_0) { - if (active.first == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else if (sdCard == sd::SLOT_1) { - if (active.second == sd::MOUNTED) { - return true; - } - else { - return false; - } - } - else { - sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl; - } + SdCardManager::SdStatePair active; + ReturnValue_t result = this->getSdCardActiveStatus(active); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "SdCardManager::isSdCardMounted: Failed to get SD card active state"; return false; + } + if (sdCard == sd::SLOT_0) { + if (active.first == sd::MOUNTED) { + return true; + } else { + return false; + } + } else if (sdCard == sd::SLOT_1) { + if (active.second == sd::MOUNTED) { + return true; + } else { + return false; + } + } else { + sif::debug << "SdCardManager::isSdCardMounted: Unknown SD card specified" << std::endl; + } + return false; } - - diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 6e4930da..4446a102 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -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 -#include -#include -#include -#include #include +#include +#include +#include +#include + +#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; @@ -24,202 +23,188 @@ class MutexIF; * state */ class SdCardManager { - friend class SdCardAccess; -public: - enum class Operations { - SWITCHING_ON, - SWITCHING_OFF, - MOUNTING, - UNMOUNTING, - IDLE - }; + friend class SdCardAccess; - enum class OpStatus { - IDLE, - TIMEOUT, - ONGOING, - SUCCESS, - FAIL - }; + public: + enum class Operations { SWITCHING_ON, SWITCHING_OFF, MOUNTING, UNMOUNTING, IDLE }; - using SdStatePair = std::pair; + enum class OpStatus { IDLE, TIMEOUT, ONGOING, SUCCESS, FAIL }; - static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; + using SdStatePair = std::pair; - 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 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 UNMOUNT_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13); - static constexpr ReturnValue_t SYSTEM_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); - static constexpr ReturnValue_t POPEN_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 15); + static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; - static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM; + 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 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 UNMOUNT_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13); + static constexpr ReturnValue_t SYSTEM_CALL_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); + static constexpr ReturnValue_t POPEN_CALL_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 15); - static constexpr Event SANITIZATION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FILE_SYSTEM; - // C++17 does not support constexpr std::string yet - static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; - static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; - static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; - static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; - static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt"; + static constexpr Event SANITIZATION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); - virtual ~SdCardManager(); + // C++17 does not support constexpr std::string yet + static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; + static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; + static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; + static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; + static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt"; - static void create(); + virtual ~SdCardManager(); - /** - * Returns the single instance of the SD card manager. - */ - static SdCardManager* instance(); + static void create(); - /** - * Set the preferred SD card which will determine which SD card will be used as the primary - * SD card in hot redundant and cold redundant mode. This function will not switch the - * SD cards which are currently on and mounted, this needs to be implemented by - * an upper layer by using #switchOffSdCard , #switchOnSdCard and #updateSdCardStateFile - * @param sdCard - * @return - */ - ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); + /** + * Returns the single instance of the SD card manager. + */ + static SdCardManager* instance(); - /** - * Get the currently configured preferred SD card - * @param sdCard - * @return - */ - ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; + /** + * Set the preferred SD card which will determine which SD card will be used as the primary + * SD card in hot redundant and cold redundant mode. This function will not switch the + * SD cards which are currently on and mounted, this needs to be implemented by + * an upper layer by using #switchOffSdCard , #switchOnSdCard and #updateSdCardStateFile + * @param sdCard + * @return + */ + ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); - /** - * Switch on the specified SD card. - * @param sdCard - * @param doMountSdCard Mount the SD card after switching it on, which is necessary - * to use it - * @param statusPair If the status pair is already available, it can be passed here - * @return - RETURN_OK on success, ALREADY_ON if it is already on, - * SYSTEM_CALL_ERROR on system error - */ - ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true, - SdStatePair* statusPair = nullptr); + /** + * Get the currently configured preferred SD card + * @param sdCard + * @return + */ + ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; - /** - * Switch off the specified SD card. - * @param sdCard - * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes - * the operation safer - * @param statusPair If the status pair is already available, it can be passed here - * @return - RETURN_OK on success, ALREADY_ON if it is already on, - * SYSTEM_CALL_ERROR on system error - */ - ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true, - SdStatePair* statusPair = nullptr); + /** + * Switch on the specified SD card. + * @param sdCard + * @param doMountSdCard Mount the SD card after switching it on, which is necessary + * to use it + * @param statusPair If the status pair is already available, it can be passed here + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ + ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true, + SdStatePair* statusPair = nullptr); - /** - * Update the state file or creates one if it does not exist. You need to call this - * function before calling #sdCardActive - * @return - * - RETURN_OK if the state file was updated successfully - * - CommandExecutor::COMMAND_PENDING: Non-blocking command is pending - * - RETURN_FAILED: blocking command failed - */ - ReturnValue_t updateSdCardStateFile(); + /** + * Switch off the specified SD card. + * @param sdCard + * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes + * the operation safer + * @param statusPair If the status pair is already available, it can be passed here + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ + ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true, + SdStatePair* statusPair = nullptr); - /** - * Get the state of the SD cards. If the state file does not exist, this function will - * take care of updating it. If it does not, the function will use the state file to get - * the status of the SD cards and set the field of the provided boolean pair. - * @param active Pair of booleans, where the first entry is the state of the first SD card - * and the second one the state of the second SD card - * @return - RETURN_OK if the state was read successfully - * - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user - * should call #updateSdCardStateFile again in that case - * - STATUS_FILE_NEXISTS if the status file does not exist - */ - ReturnValue_t getSdCardActiveStatus(SdStatePair& active); + /** + * Update the state file or creates one if it does not exist. You need to call this + * function before calling #sdCardActive + * @return + * - RETURN_OK if the state file was updated successfully + * - CommandExecutor::COMMAND_PENDING: Non-blocking command is pending + * - RETURN_FAILED: blocking command failed + */ + ReturnValue_t updateSdCardStateFile(); - /** - * Mount the specified SD card. This is necessary to use it. - * @param sdCard - * @return - */ - ReturnValue_t mountSdCard(sd::SdCard sdCard); - /** - * Unmount the specified SD card. This is recommended before switching it off. The SD card - * can't be used after it has been unmounted. - * @param sdCard - * @return - */ - ReturnValue_t unmountSdCard(sd::SdCard sdCard); + /** + * Get the state of the SD cards. If the state file does not exist, this function will + * take care of updating it. If it does not, the function will use the state file to get + * the status of the SD cards and set the field of the provided boolean pair. + * @param active Pair of booleans, where the first entry is the state of the first SD card + * and the second one the state of the second SD card + * @return - RETURN_OK if the state was read successfully + * - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user + * should call #updateSdCardStateFile again in that case + * - STATUS_FILE_NEXISTS if the status file does not exist + */ + ReturnValue_t getSdCardActiveStatus(SdStatePair& active); - /** - * In case that there is a discrepancy between the preferred SD card and the currently - * mounted one, this function will sanitize the state by attempting to mount the - * currently preferred SD card. If the caller already has state information, it can be - * passed into the function. For now, this operation will be enforced in blocking mode. - * @param statusPair Current SD card status capture with #getSdCardActiveStatus - * @param prefSdCard Preferred SD card captured with #getPreferredSdCard - * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed - * @return - */ - ReturnValue_t sanitizeState(SdStatePair* statusPair = nullptr, - sd::SdCard prefSdCard = sd::SdCard::NONE); + /** + * Mount the specified SD card. This is necessary to use it. + * @param sdCard + * @return + */ + ReturnValue_t mountSdCard(sd::SdCard sdCard); + /** + * Unmount the specified SD card. This is recommended before switching it off. The SD card + * can't be used after it has been unmounted. + * @param sdCard + * @return + */ + ReturnValue_t unmountSdCard(sd::SdCard sdCard); - /** - * If sd::SdCard::NONE is passed as an argument, this function will get the currently - * preferred SD card from the scratch buffer. - * @param prefSdCardPtr - * @return - */ - std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE); + /** + * In case that there is a discrepancy between the preferred SD card and the currently + * mounted one, this function will sanitize the state by attempting to mount the + * currently preferred SD card. If the caller already has state information, it can be + * passed into the function. For now, this operation will be enforced in blocking mode. + * @param statusPair Current SD card status capture with #getSdCardActiveStatus + * @param prefSdCard Preferred SD card captured with #getPreferredSdCard + * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed + * @return + */ + ReturnValue_t sanitizeState(SdStatePair* statusPair = nullptr, + sd::SdCard prefSdCard = sd::SdCard::NONE); - OpStatus checkCurrentOp(Operations& currentOp); + /** + * If sd::SdCard::NONE is passed as an argument, this function will get the currently + * preferred SD card from the scratch buffer. + * @param prefSdCardPtr + * @return + */ + std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE); - /** - * If there are issues with the state machine, it can be reset with this function - */ - void resetState(); + OpStatus checkCurrentOp(Operations& currentOp); - void setBlocking(bool blocking); - void setPrintCommandOutput(bool print); + /** + * If there are issues with the state machine, it can be reset with this function + */ + void resetState(); - /** - * @brief Checks if an SD card is mounted - * - * @param sdCard The SD crad to check - * - * @return true if mounted, otherwise false - */ - bool isSdCardMounted(sd::SdCard sdCard); -private: - CommandExecutor cmdExecutor; - Operations currentOp = Operations::IDLE; - bool blocking = false; - bool printCmdOutput = true; + void setBlocking(bool blocking); + void setPrintCommandOutput(bool print); - SdCardManager(); + /** + * @brief Checks if an SD card is mounted + * + * @param sdCard The SD crad to check + * + * @return true if mounted, otherwise false + */ + bool isSdCardMounted(sd::SdCard sdCard); - ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); + private: + CommandExecutor cmdExecutor; + Operations currentOp = Operations::IDLE; + bool blocking = false; + bool printCmdOutput = true; - void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx, - sd::SdCard& currentSd); + SdCardManager(); - std::string currentPrefix; + ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); - static SdCardManager* factoryInstance; + void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx, + sd::SdCard& currentSd); + + std::string currentPrefix; + + static SdCardManager* factoryInstance; }; #endif /* BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ */ diff --git a/bsp_q7s/memory/definitions.h b/bsp_q7s/memory/definitions.h index 9e0bca65..53184e4e 100644 --- a/bsp_q7s/memory/definitions.h +++ b/bsp_q7s/memory/definitions.h @@ -5,22 +5,15 @@ namespace sd { -enum SdState: uint8_t { - OFF = 0, - ON = 1, - // A mounted SD card is on as well - MOUNTED = 2 +enum SdState : uint8_t { + OFF = 0, + ON = 1, + // A mounted SD card is on as well + 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_ */ diff --git a/bsp_q7s/memory/scratchApi.cpp b/bsp_q7s/memory/scratchApi.cpp index 08d59df1..83bc8239 100644 --- a/bsp_q7s/memory/scratchApi.cpp +++ b/bsp_q7s/memory/scratchApi.cpp @@ -1,49 +1,50 @@ #include "scratchApi.h" ReturnValue_t scratch::writeString(std::string name, std::string string) { - std::ostringstream oss; - oss << "xsc_scratch write " << name << " \"" << string << "\""; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::writeString"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch write " << name << " \"" << string << "\""; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::writeString"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t scratch::readString(std::string key, std::string &string) { - std::ifstream file; - std::string filename; - ReturnValue_t result = readToFile(key, file, filename); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + std::ifstream file; + std::string filename; + ReturnValue_t result = readToFile(key, file, filename); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - std::string line; - if (not std::getline(file, line)) { - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } + std::string line; + if (not std::getline(file, line)) { + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; + } - size_t pos = line.find("="); - if(pos == std::string::npos) { - sif::warning << "scratch::readNumber: Output file format invalid, " - "no \"=\" found" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - string = line.substr(pos + 1); - return HasReturnvaluesIF::RETURN_OK; + size_t pos = line.find("="); + if (pos == std::string::npos) { + sif::warning << "scratch::readNumber: Output file format invalid, " + "no \"=\" found" + << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } + string = line.substr(pos + 1); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t scratch::clearValue(std::string key) { - std::ostringstream oss; - oss << "xsc_scratch clear " << key; - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::clearValue"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch clear " << key; + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::clearValue"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index ee19e084..babd26dc 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -1,17 +1,17 @@ #ifndef BSP_Q7S_MEMORY_SCRATCHAPI_H_ #define BSP_Q7S_MEMORY_SCRATCHAPI_H_ +#include +#include +#include +#include +#include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "linux/utility/utility.h" #include "returnvalues/classIds.h" -#include -#include -#include -#include -#include - /** * @brief API for the scratch buffer */ @@ -48,7 +48,7 @@ ReturnValue_t readString(std::string key, std::string& string); * @param num Number. Template allows to set signed, unsigned and floating point numbers * @return */ -template::value>::type> +template ::value>::type> inline ReturnValue_t writeNumber(std::string key, T num) noexcept; /** @@ -59,90 +59,88 @@ inline ReturnValue_t writeNumber(std::string key, T num) noexcept; * @param num * @return */ -template::value>::type> +template ::value>::type> inline ReturnValue_t readNumber(std::string key, T& num) noexcept; - // Anonymous namespace namespace { static uint8_t counter = 0; ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& filename) { - using namespace std; - filename = "/tmp/sro" + std::to_string(counter++); - ostringstream oss; - oss << "xsc_scratch read " << name << " > " << filename; + using namespace std; + filename = "/tmp/sro" + std::to_string(counter++); + ostringstream oss; + oss << "xsc_scratch read " << name << " > " << filename; - int result = std::system(oss.str().c_str()); - if(result != 0) { - if(result == 256) { - sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - else { - utility::handleSystemError(result, "scratch::readNumber"); - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } + int result = std::system(oss.str().c_str()); + if (result != 0) { + if (result == 256) { + sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } else { + utility::handleSystemError(result, "scratch::readNumber"); + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; } - file.open(filename); - return HasReturnvaluesIF::RETURN_OK; + } + file.open(filename); + return HasReturnvaluesIF::RETURN_OK; } -} // End of anonymous namespace +} // End of anonymous namespace -template::value>::type> +template ::value>::type> inline ReturnValue_t writeNumber(std::string key, T num) noexcept { - std::ostringstream oss; - oss << "xsc_scratch write " << key << " " << std::to_string(num); - int result = std::system(oss.str().c_str()); - if(result != 0) { - utility::handleSystemError(result, "scratch::writeNumber"); - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + std::ostringstream oss; + oss << "xsc_scratch write " << key << " " << std::to_string(num); + int result = std::system(oss.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, "scratch::writeNumber"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -template::value>::type> +template ::value>::type> inline ReturnValue_t readNumber(std::string key, T& num) noexcept { - using namespace std; - ifstream file; - std::string filename; - ReturnValue_t result = readToFile(key, file, filename); - if(result != HasReturnvaluesIF::RETURN_OK) { - std::remove(filename.c_str()); - return result; - } - - string line; - if (not std::getline(file, line)) { - std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_FAILED; - } - - size_t pos = line.find("="); - if(pos == string::npos) { - sif::warning << "scratch::readNumber: Output file format invalid, " - "no \"=\" found" << std::endl; - // Could not find value - std::remove(filename.c_str()); - return KEY_NOT_FOUND; - } - std::string valueAsString = line.substr(pos + 1); - try { - num = std::stoi(valueAsString); - } - catch(std::invalid_argument& e) { - sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl; - } - + using namespace std; + ifstream file; + std::string filename; + ReturnValue_t result = readToFile(key, file, filename); + if (result != HasReturnvaluesIF::RETURN_OK) { std::remove(filename.c_str()); - return HasReturnvaluesIF::RETURN_OK; + return result; + } + + string line; + if (not std::getline(file, line)) { + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; + } + + size_t pos = line.find("="); + if (pos == string::npos) { + sif::warning << "scratch::readNumber: Output file format invalid, " + "no \"=\" found" + << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } + std::string valueAsString = line.substr(pos + 1); + try { + num = std::stoi(valueAsString); + } catch (std::invalid_argument& e) { + sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl; + } + + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_OK; } -} +} // namespace scratch #endif /* BSP_Q7S_MEMORY_SCRATCHAPI_H_ */ diff --git a/bsp_q7s/simple/simple.cpp b/bsp_q7s/simple/simple.cpp index 960aa7db..b300e456 100644 --- a/bsp_q7s/simple/simple.cpp +++ b/bsp_q7s/simple/simple.cpp @@ -1,4 +1,5 @@ #include "simple.h" + #include "q7sConfig.h" #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 @@ -6,16 +7,13 @@ #endif int simple::simple() { - cout << "-- Q7S Simple Application --" << endl; + cout << "-- Q7S Simple Application --" << endl; #if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 - { - FileSystemTest fileSystemTest; - } + { FileSystemTest fileSystemTest; } #endif #if TE0720_GPIO_TEST #endif - return 0; + return 0; } - diff --git a/bsp_q7s/spi/Q7sSpiComIF.cpp b/bsp_q7s/spi/Q7sSpiComIF.cpp index 23dbe551..84552503 100644 --- a/bsp_q7s/spi/Q7sSpiComIF.cpp +++ b/bsp_q7s/spi/Q7sSpiComIF.cpp @@ -1,9 +1,5 @@ #include -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() {} diff --git a/bsp_q7s/spi/Q7sSpiComIF.h b/bsp_q7s/spi/Q7sSpiComIF.h index a10d63dd..def754ab 100644 --- a/bsp_q7s/spi/Q7sSpiComIF.h +++ b/bsp_q7s/spi/Q7sSpiComIF.h @@ -3,7 +3,6 @@ #include - /** * @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. @@ -17,17 +16,17 @@ * the SPI interface. The multiplexing is performed via a GPIO connected to a VHDL * module responsible for switching between the to SPI peripherals. */ -class Q7sSpiComIF: public SpiComIF { -public: - /** - * @brief Constructor - * - * @param objectId - * @param gpioComIF - * @param gpioSwitchId The gpio ID of the GPIO connected to the SPI mux module in the PL. - */ - Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF, gpioId_t gpioSwitchId); - virtual ~Q7sSpiComIF(); +class Q7sSpiComIF : public SpiComIF { + public: + /** + * @brief Constructor + * + * @param objectId + * @param gpioComIF + * @param gpioSwitchId The gpio ID of the GPIO connected to the SPI mux module in the PL. + */ + Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF, gpioId_t gpioSwitchId); + virtual ~Q7sSpiComIF(); }; #endif /* BSP_Q7S_SPI_Q7SSPICOMIF_H_ */ diff --git a/linux/archive/gpio/GpioCookie.cpp b/linux/archive/gpio/GpioCookie.cpp index c729502b..b1bb2db4 100644 --- a/linux/archive/gpio/GpioCookie.cpp +++ b/linux/archive/gpio/GpioCookie.cpp @@ -1,34 +1,32 @@ #include "GpioCookie.h" + #include -GpioCookie::GpioCookie() { -} +GpioCookie::GpioCookie() {} -ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig){ - if (gpioConfig == nullptr) { - sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { + if (gpioConfig == nullptr) { + sif::debug << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + auto gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + 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; +#endif + return HasReturnvaluesIF::RETURN_FAILED; } - auto gpioMapIter = gpioMap.find(gpioId); - if(gpioMapIter == gpioMap.end()) { - auto statusPair = gpioMap.emplace(gpioId, gpioConfig); - if (statusPair.second == false) { + return HasReturnvaluesIF::RETURN_OK; + } #if FSFW_VERBOSE_LEVEL >= 1 - sif::error << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << - " to GPIO map" << std::endl; + sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; - } -#if FSFW_VERBOSE_LEVEL >= 1 - sif::error << "GpioCookie::addGpio: GPIO already exists in GPIO map " << std::endl; -#endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; } -GpioMap GpioCookie::getGpioMap() const { - return gpioMap; -} +GpioMap GpioCookie::getGpioMap() const { return gpioMap; } GpioCookie::~GpioCookie() {} diff --git a/linux/archive/gpio/GpioCookie.h b/linux/archive/gpio/GpioCookie.h index 3f8531ee..9295a4ac 100644 --- a/linux/archive/gpio/GpioCookie.h +++ b/linux/archive/gpio/GpioCookie.h @@ -1,11 +1,12 @@ #ifndef LINUX_GPIO_GPIOCOOKIE_H_ #define LINUX_GPIO_GPIOCOOKIE_H_ -#include "GpioIF.h" -#include "gpioDefinitions.h" #include #include +#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 @@ -16,24 +17,23 @@ * * @author J. Meier */ -class GpioCookie: public CookieIF { -public: +class GpioCookie : public CookieIF { + public: + GpioCookie(); - GpioCookie(); + virtual ~GpioCookie(); - virtual ~GpioCookie(); + ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig); + /** + * @brief Get map with registered GPIOs. + */ + GpioMap getGpioMap() const; - ReturnValue_t addGpio(gpioId_t gpioId, GpioBase* gpioConfig); - /** - * @brief Get map with registered GPIOs. - */ - GpioMap getGpioMap() const; - -private: - /** - * Returns a copy of the internal GPIO map. - */ - GpioMap gpioMap; + private: + /** + * Returns a copy of the internal GPIO map. + */ + GpioMap gpioMap; }; #endif /* LINUX_GPIO_GPIOCOOKIE_H_ */ diff --git a/linux/archive/gpio/GpioIF.h b/linux/archive/gpio/GpioIF.h index 75feb3ce..045af556 100644 --- a/linux/archive/gpio/GpioIF.h +++ b/linux/archive/gpio/GpioIF.h @@ -1,9 +1,10 @@ #ifndef LINUX_GPIO_GPIOIF_H_ #define LINUX_GPIO_GPIOIF_H_ -#include "gpioDefinitions.h" -#include #include +#include + +#include "gpioDefinitions.h" class GpioCookie; @@ -13,42 +14,41 @@ class GpioCookie; * @author J. Meier */ class GpioIF : public HasReturnvaluesIF { -public: + public: + virtual ~GpioIF(){}; - virtual ~GpioIF() {}; + /** + * @brief Called by the GPIO using object. + * @param cookie Cookie specifying informations of the GPIOs required + * by a object. + */ + virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0; - /** - * @brief Called by the GPIO using object. - * @param cookie Cookie specifying informations of the GPIOs required - * by a object. - */ - virtual ReturnValue_t addGpios(GpioCookie* cookie) = 0; + /** + * @brief By implementing this function a child must provide the + * functionality to pull a certain GPIO to high logic level. + * + * @param gpioId A unique number which specifies the GPIO to drive. + * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. + */ + virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; - /** - * @brief By implementing this function a child must provide the - * functionality to pull a certain GPIO to high logic level. - * - * @param gpioId A unique number which specifies the GPIO to drive. - * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. - */ - virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; + /** + * @brief By implementing this function a child must provide the + * functionality to pull a certain GPIO to low logic level. + * + * @param gpioId A unique number which specifies the GPIO to drive. + */ + virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0; - /** - * @brief By implementing this function a child must provide the - * functionality to pull a certain GPIO to low logic level. - * - * @param gpioId A unique number which specifies the GPIO to drive. - */ - virtual ReturnValue_t pullLow(gpioId_t gpioId) = 0; - - /** - * @brief This function requires a child to implement the functionality to read the state of - * an ouput or input gpio. - * - * @param gpioId A unique number which specifies the GPIO to read. - * @param gpioState State of GPIO will be written to this pointer. - */ - virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0; + /** + * @brief This function requires a child to implement the functionality to read the state of + * an ouput or input gpio. + * + * @param gpioId A unique number which specifies the GPIO to read. + * @param gpioState State of GPIO will be written to this pointer. + */ + virtual ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) = 0; }; #endif /* LINUX_GPIO_GPIOIF_H_ */ diff --git a/linux/archive/gpio/LinuxLibgpioIF.cpp b/linux/archive/gpio/LinuxLibgpioIF.cpp index 92ffa63c..e5dcc1f2 100644 --- a/linux/archive/gpio/LinuxLibgpioIF.cpp +++ b/linux/archive/gpio/LinuxLibgpioIF.cpp @@ -1,302 +1,295 @@ #include "LinuxLibgpioIF.h" -#include "GpioCookie.h" #include +#include #include +#include #include -#include -#include +#include "GpioCookie.h" LinuxLibgpioIF::LinuxLibgpioIF(object_id_t objectId) : SystemObject(objectId) { - struct gpiod_chip* chip = gpiod_chip_open_by_label("/amba_pl/gpio@42030000"); + struct gpiod_chip* chip = gpiod_chip_open_by_label("/amba_pl/gpio@42030000"); - sif::debug << chip->name << std::endl; + sif::debug << chip->name << std::endl; } -LinuxLibgpioIF::~LinuxLibgpioIF() { -} +LinuxLibgpioIF::~LinuxLibgpioIF() {} ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) { - ReturnValue_t result; - if(gpioCookie == nullptr) { - sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl; - return RETURN_FAILED; - } + ReturnValue_t result; + if (gpioCookie == nullptr) { + sif::error << "LinuxLibgpioIF::initialize: Invalid cookie" << std::endl; + return RETURN_FAILED; + } - GpioMap mapToAdd = gpioCookie->getGpioMap(); + GpioMap mapToAdd = gpioCookie->getGpioMap(); - /* Check whether this ID already exists in the map and remove duplicates */ - result = checkForConflicts(mapToAdd); - if (result != RETURN_OK){ - return result; - } + /* Check whether this ID already exists in the map and remove duplicates */ + result = checkForConflicts(mapToAdd); + if (result != RETURN_OK) { + return result; + } - result = configureGpios(mapToAdd); - if (result != RETURN_OK) { - return RETURN_FAILED; - } + result = configureGpios(mapToAdd); + if (result != RETURN_OK) { + return RETURN_FAILED; + } - /* Register new GPIOs in gpioMap */ - gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); + /* Register new GPIOs in gpioMap */ + gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) { - for(auto& gpioConfig: mapToAdd) { - switch(gpioConfig.second->gpioType) { - case(gpio::GpioTypes::NONE): { - return GPIO_INVALID_INSTANCE; - } - case(gpio::GpioTypes::GPIOD_REGULAR): { - GpiodRegular* regularGpio = dynamic_cast(gpioConfig.second); - if(regularGpio == nullptr) { - return GPIO_INVALID_INSTANCE; - } - configureRegularGpio(gpioConfig.first, regularGpio); - break; - } - case(gpio::GpioTypes::CALLBACK): { - auto gpioCallback = dynamic_cast(gpioConfig.second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioConfig.first, gpio::GpioOperation::WRITE, - gpioCallback->initValue, gpioCallback->callbackArgs); + for (auto& gpioConfig : mapToAdd) { + switch (gpioConfig.second->gpioType) { + case (gpio::GpioTypes::NONE): { + return GPIO_INVALID_INSTANCE; + } + case (gpio::GpioTypes::GPIOD_REGULAR): { + GpiodRegular* regularGpio = dynamic_cast(gpioConfig.second); + if (regularGpio == nullptr) { + return GPIO_INVALID_INSTANCE; } + configureRegularGpio(gpioConfig.first, regularGpio); + break; + } + case (gpio::GpioTypes::CALLBACK): { + auto gpioCallback = dynamic_cast(gpioConfig.second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } + gpioCallback->callback(gpioConfig.first, gpio::GpioOperation::WRITE, + gpioCallback->initValue, gpioCallback->callbackArgs); + } } - return RETURN_OK; + } + return RETURN_OK; } -ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular *regularGpio) { - std::string chipname; - unsigned int lineNum; - struct gpiod_chip *chip; - gpio::Direction direction; - std::string consumer; - struct gpiod_line *lineHandle; - int result = 0; +ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular* regularGpio) { + std::string chipname; + unsigned int lineNum; + struct gpiod_chip* chip; + gpio::Direction direction; + std::string consumer; + struct gpiod_line* lineHandle; + int result = 0; - 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; + 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; + 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; + gpiod_chip_close(chip); + return RETURN_FAILED; + } + + direction = regularGpio->direction; + consumer = regularGpio->consumer; + /* 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); + if (result < 0) { + 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; } - - 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; - gpiod_chip_close(chip); + 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; + gpiod_line_release(lineHandle); return RETURN_FAILED; - } - - direction = regularGpio->direction; - consumer = regularGpio->consumer; - /* 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); - if (result < 0) { - 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; - } - 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; - gpiod_line_release(lineHandle); - return RETURN_FAILED; - } - break; + } + break; } default: { - sif::error << "LinuxLibgpioIF::configureGpios: Invalid direction specified" - << std::endl; - return GPIO_INVALID_INSTANCE; + 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 - * read states of GPIOs. - */ - regularGpio->lineHandle = lineHandle; - return RETURN_OK; + } + /** + * Write line handle to GPIO configuration instance so it can later be used to set or + * read states of GPIOs. + */ + regularGpio->lineHandle = lineHandle; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()) { - sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; - } + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 1); + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 1); + } else { + auto gpioCallback = dynamic_cast(gpioMapIter->second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } - else { - auto gpioCallback = dynamic_cast(gpioMapIter->second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, - 1, gpioCallback->callbackArgs); - } - return GPIO_TYPE_FAILURE; + gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, 1, + gpioCallback->callbackArgs); + } + return GPIO_TYPE_FAILURE; } ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()) { - sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; - } + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::driveGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 0); + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + return driveGpio(gpioId, dynamic_cast(gpioMapIter->second), 0); + } else { + auto gpioCallback = dynamic_cast(gpioMapIter->second); + if (gpioCallback->callback == nullptr) { + return GPIO_INVALID_INSTANCE; } - else { - auto gpioCallback = dynamic_cast(gpioMapIter->second); - if(gpioCallback->callback == nullptr) { - return GPIO_INVALID_INSTANCE; - } - gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, - 0, gpioCallback->callbackArgs); - } - return GPIO_TYPE_FAILURE; + 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) { - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } +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; - return DRIVE_GPIO_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; + return DRIVE_GPIO_FAILURE; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) { - gpioMapIter = gpioMap.find(gpioId); - if (gpioMapIter == gpioMap.end()){ - sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; - return UNKNOWN_GPIO_ID; + gpioMapIter = gpioMap.find(gpioId); + if (gpioMapIter == gpioMap.end()) { + sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; + return UNKNOWN_GPIO_ID; + } + + if (gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { + GpiodRegular* regularGpio = dynamic_cast(gpioMapIter->second); + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; } + *gpioState = gpiod_line_get_value(regularGpio->lineHandle); + } else { + } - if(gpioMapIter->second->gpioType == gpio::GpioTypes::GPIOD_REGULAR) { - GpiodRegular* regularGpio = dynamic_cast(gpioMapIter->second); - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - *gpioState = gpiod_line_get_value(regularGpio->lineHandle); - } - else { - - } - - - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd){ - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for(auto& gpioConfig: mapToAdd) { - switch(gpioConfig.second->gpioType) { - case(gpio::GpioTypes::GPIOD_REGULAR): { - auto regularGpio = dynamic_cast(gpioConfig.second); - if(regularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - /* Check for conflicts and remove duplicates if necessary */ - result = checkForConflictsRegularGpio(gpioConfig.first, regularGpio, mapToAdd); - if(result != HasReturnvaluesIF::RETURN_OK) { - status = result; - } - break; +ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { + ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + for (auto& gpioConfig : mapToAdd) { + switch (gpioConfig.second->gpioType) { + case (gpio::GpioTypes::GPIOD_REGULAR): { + auto regularGpio = dynamic_cast(gpioConfig.second); + if (regularGpio == nullptr) { + return GPIO_TYPE_FAILURE; } - case(gpio::GpioTypes::CALLBACK): { - auto callbackGpio = dynamic_cast(gpioConfig.second); - if(callbackGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - /* Check for conflicts and remove duplicates if necessary */ - result = checkForConflictsCallbackGpio(gpioConfig.first, callbackGpio, mapToAdd); - if(result != HasReturnvaluesIF::RETURN_OK) { - status = result; - } - break; + /* Check for conflicts and remove duplicates if necessary */ + result = checkForConflictsRegularGpio(gpioConfig.first, regularGpio, mapToAdd); + if (result != HasReturnvaluesIF::RETURN_OK) { + status = result; } - default: { - + break; + } + case (gpio::GpioTypes::CALLBACK): { + auto callbackGpio = dynamic_cast(gpioConfig.second); + if (callbackGpio == nullptr) { + return GPIO_TYPE_FAILURE; } + /* Check for conflicts and remove duplicates if necessary */ + result = checkForConflictsCallbackGpio(gpioConfig.first, callbackGpio, mapToAdd); + if (result != HasReturnvaluesIF::RETURN_OK) { + status = result; } + break; + } + default: { + } } - return status; + } + return status; } - ReturnValue_t LinuxLibgpioIF::checkForConflictsRegularGpio(gpioId_t gpioIdToCheck, - 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; - mapToAdd.erase(gpioIdToCheck); - return HasReturnvaluesIF::RETURN_OK; - } - auto ownRegularGpio = dynamic_cast(gpioMapIter->second); - if(ownRegularGpio == nullptr) { - return GPIO_TYPE_FAILURE; - } - - /* Remove element from map to add because a entry for this GPIO - already exists */ - sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" - << " detected. Duplicate will be removed from map to add." << std::endl; - mapToAdd.erase(gpioIdToCheck); + 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; + mapToAdd.erase(gpioIdToCheck); + return HasReturnvaluesIF::RETURN_OK; } - return HasReturnvaluesIF::RETURN_OK; + auto ownRegularGpio = dynamic_cast(gpioMapIter->second); + if (ownRegularGpio == nullptr) { + return GPIO_TYPE_FAILURE; + } + + /* Remove element from map to add because a entry for this GPIO + already exists */ + sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" + << " detected. Duplicate will be removed from map to add." << std::endl; + mapToAdd.erase(gpioIdToCheck); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t LinuxLibgpioIF::checkForConflictsCallbackGpio(gpioId_t gpioIdToCheck, - 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; - mapToAdd.erase(gpioIdToCheck); - return HasReturnvaluesIF::RETURN_OK; - } - - /* Remove element from map to add because a entry for this GPIO - already exists */ - sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" - << " detected. Duplicate will be removed from map to add." << std::endl; - mapToAdd.erase(gpioIdToCheck); + 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; + mapToAdd.erase(gpioIdToCheck); + return HasReturnvaluesIF::RETURN_OK; } - return HasReturnvaluesIF::RETURN_OK; + + /* Remove element from map to add because a entry for this GPIO + already exists */ + sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition" + << " detected. Duplicate will be removed from map to add." << std::endl; + mapToAdd.erase(gpioIdToCheck); + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/archive/gpio/LinuxLibgpioIF.h b/linux/archive/gpio/LinuxLibgpioIF.h index 9c444e50..1c974efb 100644 --- a/linux/archive/gpio/LinuxLibgpioIF.h +++ b/linux/archive/gpio/LinuxLibgpioIF.h @@ -1,9 +1,9 @@ #ifndef LINUX_GPIO_LINUXLIBGPIOIF_H_ #define LINUX_GPIO_LINUXLIBGPIOIF_H_ -#include -#include #include +#include +#include class GpioCookie; @@ -15,63 +15,61 @@ class GpioCookie; * 2019.1. */ class LinuxLibgpioIF : public GpioIF, public SystemObject { -public: + public: + static const uint8_t gpioRetvalId = CLASS_ID::LINUX_LIBGPIO_IF; - static const uint8_t gpioRetvalId = CLASS_ID::LINUX_LIBGPIO_IF; + static constexpr ReturnValue_t UNKNOWN_GPIO_ID = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1); + static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2); + static constexpr ReturnValue_t GPIO_TYPE_FAILURE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3); + static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = + HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4); - static constexpr ReturnValue_t UNKNOWN_GPIO_ID = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1); - static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2); - static constexpr ReturnValue_t GPIO_TYPE_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3); - static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4); + LinuxLibgpioIF(object_id_t objectId); + virtual ~LinuxLibgpioIF(); - LinuxLibgpioIF(object_id_t objectId); - virtual ~LinuxLibgpioIF(); + ReturnValue_t addGpios(GpioCookie* gpioCookie) override; + ReturnValue_t pullHigh(gpioId_t gpioId) override; + ReturnValue_t pullLow(gpioId_t gpioId) override; + ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override; - ReturnValue_t addGpios(GpioCookie* gpioCookie) override; - ReturnValue_t pullHigh(gpioId_t gpioId) override; - ReturnValue_t pullLow(gpioId_t gpioId) override; - ReturnValue_t readGpio(gpioId_t gpioId, int* gpioState) override; + private: + /* Holds the information and configuration of all used GPIOs */ + GpioMap gpioMap; + GpioMapIter gpioMapIter; -private: - /* Holds the information and configuration of all used GPIOs */ - GpioMap gpioMap; - GpioMapIter gpioMapIter; + /** + * @brief This functions drives line of a GPIO specified by the GPIO ID. + * + * @param gpioId The GPIO ID of the GPIO to drive. + * @param logiclevel The logic level to set. O or 1. + */ + ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio, unsigned int logiclevel); - /** - * @brief This functions drives line of a GPIO specified by the GPIO ID. - * - * @param gpioId The GPIO ID of the GPIO to drive. - * @param logiclevel The logic level to set. O or 1. - */ - ReturnValue_t driveGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio, unsigned int logiclevel); + ReturnValue_t configureRegularGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio); - ReturnValue_t configureRegularGpio(gpioId_t gpioId, GpiodRegularBase& regularGpio); + /** + * @brief This function checks if GPIOs are already registered and whether + * there exists a conflict in the GPIO configuration. E.g. the + * direction. + * + * @param mapToAdd The GPIOs which shall be added to the gpioMap. + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED + */ + ReturnValue_t checkForConflicts(GpioMap& mapToAdd); - /** - * @brief This function checks if GPIOs are already registered and whether - * there exists a conflict in the GPIO configuration. E.g. the - * direction. - * - * @param mapToAdd The GPIOs which shall be added to the gpioMap. - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED - */ - ReturnValue_t checkForConflicts(GpioMap& mapToAdd); - - ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegular* regularGpio, - GpioMap& mapToAdd); - ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio, - GpioMap& mapToAdd); - - /** - * @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd. - */ - ReturnValue_t configureGpios(GpioMap& mapToAdd); + ReturnValue_t checkForConflictsRegularGpio(gpioId_t gpiodId, GpiodRegular* regularGpio, + GpioMap& mapToAdd); + ReturnValue_t checkForConflictsCallbackGpio(gpioId_t gpiodId, GpioCallback* regularGpio, + GpioMap& mapToAdd); + /** + * @brief Performs the initial configuration of all GPIOs specified in the GpioMap mapToAdd. + */ + ReturnValue_t configureGpios(GpioMap& mapToAdd); }; #endif /* LINUX_GPIO_LINUXLIBGPIOIF_H_ */ diff --git a/linux/archive/gpio/gpioDefinitions.h b/linux/archive/gpio/gpioDefinitions.h index 66c0b005..0db4db11 100644 --- a/linux/archive/gpio/gpioDefinitions.h +++ b/linux/archive/gpio/gpioDefinitions.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 @@ -47,51 +34,49 @@ static constexpr gpioId_t NO_GPIO = -1; * pointer. */ class GpioBase { -public: + public: + GpioBase() = default; - 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(){}; - virtual~ GpioBase() {}; - - /* Can be used to cast GpioBase to a concrete child implementation */ - gpio::GpioTypes gpioType = gpio::GpioTypes::NONE; - std::string consumer; - gpio::Direction direction = gpio::Direction::IN; - int initValue = 0; + /* Can be used to cast GpioBase to a concrete child implementation */ + gpio::GpioTypes gpioType = gpio::GpioTypes::NONE; + std::string consumer; + gpio::Direction direction = gpio::Direction::IN; + int initValue = 0; }; -class GpiodRegular: public GpioBase { -public: - GpiodRegular(): GpioBase(gpio::GpioTypes::GPIOD_REGULAR, std::string(), - gpio::Direction::IN, 0) {}; +class GpiodRegular : public GpioBase { + public: + 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_) {} - std::string chipname; - int lineNum = 0; - struct gpiod_line* lineHandle = nullptr; + 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_) {} + std::string chipname; + int lineNum = 0; + struct gpiod_line* lineHandle = nullptr; }; -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) {} +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 (* callback) (gpioId_t gpioId, gpio::GpioOperation gpioOp, - int value, void* args) = nullptr; - void* callbackArgs = nullptr; + void (*callback)(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value, void* args) = nullptr; + void* callbackArgs = nullptr; }; - using GpioMap = std::unordered_map; using GpioMapIter = GpioMap::iterator; diff --git a/linux/archive/tmtc/CCSDSIPCoreBridge.cpp b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp index 982f7fc2..607ccebd 100644 --- a/linux/archive/tmtc/CCSDSIPCoreBridge.cpp +++ b/linux/archive/tmtc/CCSDSIPCoreBridge.cpp @@ -1,136 +1,128 @@ -#include #include - #include +#include 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(); + ReturnValue_t result = TmTcBridge::initialize(); - fd = open("/dev/uio0", O_RDWR); - if (fd < 1) { - sif::debug << "CCSDSIPCoreBridge::initialize: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } + fd = open("/dev/uio0", O_RDWR); + if (fd < 1) { + sif::debug << "CCSDSIPCoreBridge::initialize: Invalid UIO device file" << std::endl; + return RETURN_FAILED; + } - /** - * Map uio device in virtual address space - * PROT_WRITE: Map uio device in writable only mode - */ - ptmeBaseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, 0)); + /** + * Map uio device in virtual address space + * PROT_WRITE: Map uio device in writable only mode + */ + ptmeBaseAddress = + static_cast(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; - return RETURN_FAILED; - } + if (ptmeBaseAddress == MAP_FAILED) { + sif::error << "CCSDSIPCoreBridge::initialize: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return result; + return result; } ReturnValue_t CCSDSIPCoreBridge::handleTm() { - #if OBSW_TEST_CCSDS_PTME == 1 - return sendTestFrame(); + return sendTestFrame(); #else - return TmTcBridge::handleTm(); + return TmTcBridge::handleTm(); #endif - } -ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) { +ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t* data, size_t dataLen) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } - if(pollPapbBusySignal() == RETURN_OK) { - startPacketTransfer(); + for (size_t idx = 0; idx < dataLen; idx++) { + if (pollPapbBusySignal() == RETURN_OK) { + *(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast(*(data + idx)); + } else { + sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen + << " data" << std::endl; + return RETURN_FAILED; } + } - for(size_t idx = 0; idx < dataLen; idx++) { - if(pollPapbBusySignal() == RETURN_OK) { - *(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast(*(data + idx)); - } - else { - sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen - << " data" << std::endl; - return RETURN_FAILED; - } - } - - if(pollPapbBusySignal() == RETURN_OK) { - endPacketTransfer(); - } - return RETURN_OK; + if (pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + 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; - ReturnValue_t result = RETURN_OK; + int papbBusyState = 0; + ReturnValue_t result = RETURN_OK; - /** Check if PAPB interface is ready to receive data */ - result = gpioComIF->readGpio(papbBusyId, &papbBusyState); - if (result != RETURN_OK) { - sif::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: Failed to read papb busy signal" - << std::endl; - return RETURN_FAILED; - } - if (!papbBusyState) { - sif::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: PAPB busy" << std::endl; - return PAPB_BUSY; - } + /** Check if PAPB interface is ready to receive data */ + result = gpioComIF->readGpio(papbBusyId, &papbBusyState); + if (result != RETURN_OK) { + sif::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } - return RETURN_OK; + return RETURN_OK; } void CCSDSIPCoreBridge::isPtmeBufferEmpty() { - ReturnValue_t result = RETURN_OK; - int papbEmptyState = 1; + ReturnValue_t result = RETURN_OK; + int papbEmptyState = 1; - result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); + result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); - if (result != RETURN_OK) { - sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Failed to read papb empty signal" - << std::endl; - return; - } - - if (papbEmptyState == 1) { - sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl; - } - else { - sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl; - } + if (result != RETURN_OK) { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Failed to read papb empty signal" + << std::endl; return; + } + + if (papbEmptyState == 1) { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl; + } else { + sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl; + } + return; } ReturnValue_t CCSDSIPCoreBridge::sendTestFrame() { - /** Size of one complete transfer frame data field amounts to 1105 bytes */ - uint8_t testPacket[1105]; + /** Size of one complete transfer frame data field amounts to 1105 bytes */ + uint8_t testPacket[1105]; - /** Fill one test packet */ - for(int idx = 0; idx < 1105; idx++) { - testPacket[idx] = static_cast(idx & 0xFF); - } + /** Fill one test packet */ + for (int idx = 0; idx < 1105; idx++) { + testPacket[idx] = static_cast(idx & 0xFF); + } - ReturnValue_t result = sendTm(testPacket, 1105); - if(result != RETURN_OK) { - return result; - } + ReturnValue_t result = sendTm(testPacket, 1105); + if (result != RETURN_OK) { + return result; + } - return RETURN_OK; + return RETURN_OK; } diff --git a/linux/archive/tmtc/CCSDSIPCoreBridge.h b/linux/archive/tmtc/CCSDSIPCoreBridge.h index 2ba68a3a..074769c4 100644 --- a/linux/archive/tmtc/CCSDSIPCoreBridge.h +++ b/linux/archive/tmtc/CCSDSIPCoreBridge.h @@ -1,131 +1,129 @@ #ifndef MISSION_OBC_CCSDSIPCOREBRIDGE_H_ #define MISSION_OBC_CCSDSIPCOREBRIDGE_H_ -#include "OBSWConfig.h" #include #include #include #include +#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 * on the programmable logic and are accessible through the linux UIO driver. */ -class CCSDSIPCoreBridge: public TmTcBridge { -public: - /** - * @brief Constructor - * - * @param objectId - * @param tcDestination - * @param tmStoreId - * @param tcStoreId - * @param uioPtme Name of the uio device file which provides access to the PTME IP Core. - * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the - * PTME IP Core. A low logic level indicates the PTME is not ready to - * receive more data. - * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the - * PTME IP Core. The signal is high when there are no packets in the - * external buffer memory (BRAM). - */ - 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); - virtual ~CCSDSIPCoreBridge(); +class CCSDSIPCoreBridge : public TmTcBridge { + public: + /** + * @brief Constructor + * + * @param objectId + * @param tcDestination + * @param tmStoreId + * @param tcStoreId + * @param uioPtme Name of the uio device file which provides access to the PTME IP Core. + * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the + * PTME IP Core. A low logic level indicates the PTME is not ready to + * receive more data. + * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the + * PTME IP Core. The signal is high when there are no packets in the + * external buffer memory (BRAM). + */ + 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); + virtual ~CCSDSIPCoreBridge(); - ReturnValue_t initialize() override; + ReturnValue_t initialize() override; -protected: + protected: + /** + * Overwriting this function to provide the capability of testing the PTME IP Core + * implementation. + */ + virtual ReturnValue_t handleTm() override; - /** - * Overwriting this function to provide the capability of testing the PTME IP Core - * implementation. - */ - virtual ReturnValue_t handleTm() override; + virtual ReturnValue_t sendTm(const uint8_t* data, size_t dataLen) override; - 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; -private: + static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; + /** Size of mapped address space. 4k (minimal size of pl device) */ + // static const int MAP_SIZE = 0xFA0; + static const int MAP_SIZE = 0x1000; - static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to PTME the start of a new telemetry packet + */ + static const uint32_t PTME_CONFIG_START = 0x8; + /** + * Writing this word to the ptme base address signals to the PTME that a complete tm packet has + * been transferred. + */ + static const uint32_t PTME_CONFIG_END = 0x0; - /** Size of mapped address space. 4k (minimal size of pl device) */ -// static const int MAP_SIZE = 0xFA0; - static const int MAP_SIZE = 0x1000; + /** + * Writing to this offset within the PTME memory space will insert data for encoding to the + * PTME IP core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int PTME_DATA_REG_OFFSET = 256; - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to PTME the start of a new telemetry packet - */ - static const uint32_t PTME_CONFIG_START = 0x8; + LinuxLibgpioIF* gpioComIF = nullptr; - /** - * Writing this word to the ptme base address signals to the PTME that a complete tm packet has - * been transferred. - */ - static const uint32_t PTME_CONFIG_END = 0x0; + /** The uio device file related to the PTME IP Core */ + std::string uioPtme; - /** - * Writing to this offset within the PTME memory space will insert data for encoding to the - * PTME IP core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int PTME_DATA_REG_OFFSET = 256; + /** Pulled to low when PTME not ready to receive data */ + gpioId_t papbBusyId = gpio::NO_GPIO; - LinuxLibgpioIF* gpioComIF = nullptr; + /** High when externally buffer memory of PTME is empty */ + gpioId_t papbEmptyId = gpio::NO_GPIO; - /** The uio device file related to the PTME IP Core */ - std::string uioPtme; + /** The file descriptor of the UIO driver */ + int fd; - /** Pulled to low when PTME not ready to receive data */ - gpioId_t papbBusyId = gpio::NO_GPIO; + uint32_t* ptmeBaseAddress = nullptr; - /** High when externally buffer memory of PTME is empty */ - gpioId_t papbEmptyId = gpio::NO_GPIO; + /** + * @brief This function sends the config byte to the PTME IP Core to initiate a packet + * transfer. + */ + void startPacketTransfer(); - /** The file descriptor of the UIO driver */ - int fd; + /** + * @brief This function sends the config byte to the PTME IP Core to signal the end of a + * packet transfer. + */ + void endPacketTransfer(); - uint32_t* ptmeBaseAddress = nullptr; + /** + * @brief This function reads the papb busy signal indicating whether the PAPB interface is + * ready to receive more data or not. PAPB is ready when PAPB_Busy_N == '1'. + * + * @return RETURN_OK when ready to receive data else PAPB_BUSY. + */ + ReturnValue_t pollPapbBusySignal(); - /** - * @brief This function sends the config byte to the PTME IP Core to initiate a packet - * transfer. - */ - void startPacketTransfer(); + /** + * @brief This function can be used for debugging to check wheter there are packets in + * the packet buffer of the PTME or not. + */ + void isPtmeBufferEmpty(); - /** - * @brief This function sends the config byte to the PTME IP Core to signal the end of a - * packet transfer. - */ - void endPacketTransfer(); - - /** - * @brief This function reads the papb busy signal indicating whether the PAPB interface is - * ready to receive more data or not. PAPB is ready when PAPB_Busy_N == '1'. - * - * @return RETURN_OK when ready to receive data else PAPB_BUSY. - */ - ReturnValue_t pollPapbBusySignal(); - - /** - * @brief This function can be used for debugging to check wheter there are packets in - * the packet buffer of the PTME or not. - */ - void isPtmeBufferEmpty(); - - /** - * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) - * to the input of the PTME IP Core. Can be used to test the implementation. - */ - ReturnValue_t sendTestFrame(); + /** + * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) + * to the input of the PTME IP Core. Can be used to test the implementation. + */ + ReturnValue_t sendTestFrame(); }; #endif /* MISSION_OBC_CCSDSIPCOREBRIDGE_H_ */ diff --git a/linux/boardtest/I2cTestClass.cpp b/linux/boardtest/I2cTestClass.cpp index 66c16b33..090691e2 100644 --- a/linux/boardtest/I2cTestClass.cpp +++ b/linux/boardtest/I2cTestClass.cpp @@ -1,8 +1,5 @@ #include -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; } diff --git a/linux/boardtest/I2cTestClass.h b/linux/boardtest/I2cTestClass.h index 172a7f71..314f9dda 100644 --- a/linux/boardtest/I2cTestClass.h +++ b/linux/boardtest/I2cTestClass.h @@ -3,15 +3,13 @@ #include -class I2cTestClass: public TestTask { -public: - I2cTestClass(object_id_t objectId); +class I2cTestClass : public TestTask { + public: + I2cTestClass(object_id_t objectId); - ReturnValue_t performPeriodicAction() override; -private: + ReturnValue_t performPeriodicAction() override; + private: }; - - #endif /* LINUX_BOARDTEST_I2CTESTCLASS_H_ */ diff --git a/linux/boardtest/LibgpiodTest.cpp b/linux/boardtest/LibgpiodTest.cpp index 8eb9b536..0c5ebe2a 100644 --- a/linux/boardtest/LibgpiodTest.cpp +++ b/linux/boardtest/LibgpiodTest.cpp @@ -1,135 +1,127 @@ #include "LibgpiodTest.h" +#include +#include +#include + #include "devices/gpioIds.h" -#include -#include -#include - -LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, - GpioCookie* gpioCookie): - TestTask(objectId) { - - gpioInterface = ObjectManager::instance()->get(gpioIfobjectId); - if (gpioInterface == nullptr) { - sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl; - } - gpioInterface->addGpios(gpioCookie); - testCase = TestCases::BLINK; +LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie) + : TestTask(objectId) { + gpioInterface = ObjectManager::instance()->get(gpioIfobjectId); + if (gpioInterface == nullptr) { + sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl; + } + gpioInterface->addGpios(gpioCookie); + testCase = TestCases::BLINK; } -LibgpiodTest::~LibgpiodTest() { -} +LibgpiodTest::~LibgpiodTest() {} ReturnValue_t LibgpiodTest::performPeriodicAction() { - int gpioState; - ReturnValue_t result; + int gpioState; + ReturnValue_t result; - switch(testCase) { - 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; - return RETURN_FAILED; - } - else { - sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState - << std::endl; - } - break; + switch (testCase) { + 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; + return RETURN_FAILED; + } else { + sif::debug << "LibgpiodTest::performPeriodicAction: MIO 0 state = " << gpioState + << std::endl; + } + break; } - case(TestCases::LOOPBACK): { - break; + case (TestCases::LOOPBACK): { + break; } - case(TestCases::BLINK): { - result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + 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; + return RETURN_FAILED; + } + if (gpioState == 1) { + result = gpioInterface->pullLow(gpioIds::TEST_ID_0); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " - << std::endl; - return RETURN_FAILED; + sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO low!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - if (gpioState == 1) { - result = gpioInterface->pullLow(gpioIds::TEST_ID_0); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO low!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - } - 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 { - sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl; + } 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 { + sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl; + } - break; + break; } default: - sif::debug << "LibgpiodTest::performPeriodicAction: Invalid test case" << std::endl; - break; - } + sif::debug << "LibgpiodTest::performPeriodicAction: Invalid test case" << std::endl; + break; + } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t LibgpiodTest::performOneShotAction() { - int gpioState; - ReturnValue_t result; + int gpioState; + ReturnValue_t result; - switch(testCase) { - case(TestCases::READ): { - break; + switch (testCase) { + case (TestCases::READ): { + break; } - case(TestCases::BLINK): { - break; + case (TestCases::BLINK): { + break; } - case(TestCases::LOOPBACK): { - 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 { - sif::warning << "LibgpiodTest::performOneShotAction: Could not pull GPIO high!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - 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 { - sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not high!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } + case (TestCases::LOOPBACK): { + 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 { + sif::warning << "LibgpiodTest::performOneShotAction: Could not pull GPIO high!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } + 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 { + sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not high!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } - 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; - } - 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 { - sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not low!" - << std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - break; + 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; + } + 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 { + sif::warning << "LibgpiodTest::performOneShotAction: GPIO read and is not low!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/LibgpiodTest.h b/linux/boardtest/LibgpiodTest.h index 718d0209..4fcaffdf 100644 --- a/linux/boardtest/LibgpiodTest.h +++ b/linux/boardtest/LibgpiodTest.h @@ -1,34 +1,31 @@ #ifndef TEST_TESTTASKS_LIBGPIODTEST_H_ #define TEST_TESTTASKS_LIBGPIODTEST_H_ -#include "TestTask.h" -#include -#include #include +#include +#include + +#include "TestTask.h" /** * @brief Test for the GPIO read implementation of the LinuxLibgpioIF. * @author J. Meier */ -class LibgpiodTest: public TestTask { -public: - enum TestCases { - READ = 0, - LOOPBACK = 1, - BLINK - }; +class LibgpiodTest : public TestTask { + public: + enum TestCases { READ = 0, LOOPBACK = 1, BLINK }; - TestCases testCase; + TestCases testCase; - LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie); - virtual ~LibgpiodTest(); + LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, GpioCookie* gpioCookie); + virtual ~LibgpiodTest(); -protected: - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; + protected: + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; -private: - GpioIF* gpioInterface; + private: + GpioIF* gpioInterface; }; #endif /* TEST_TESTTASKS_LIBGPIODTEST_H_ */ diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 65f2ca9f..7ef76d95 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -1,503 +1,483 @@ #include "SpiTestClass.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + #include "devices/gpioIds.h" -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF* gpioIF): TestTask(objectId), -gpioIF(gpioIF) { - if(gpioIF == nullptr) { - sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; - } - testMode = TestModes::MGM_LIS3MDL; - spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); - spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); +SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF *gpioIF) + : TestTask(objectId), gpioIF(gpioIF) { + if (gpioIF == nullptr) { + sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; + } + testMode = TestModes::MGM_LIS3MDL; + spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); + spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); } ReturnValue_t SpiTestClass::performOneShotAction() { - switch(testMode) { - case(TestModes::NONE): { - break; + switch (testMode) { + case (TestModes::NONE): { + break; } - case(TestModes::MGM_LIS3MDL): { - performLis3MdlTest(mgm0Lis3mdlChipSelect); - break; + case (TestModes::MGM_LIS3MDL): { + performLis3MdlTest(mgm0Lis3mdlChipSelect); + break; } - case(TestModes::MGM_RM3100): { - performRm3100Test(mgm1Rm3100ChipSelect); - break; + case (TestModes::MGM_RM3100): { + performRm3100Test(mgm1Rm3100ChipSelect); + break; } - case(TestModes::GYRO_L3GD20H): { - performL3gTest(gyro1L3gd20ChipSelect); - break; + case (TestModes::GYRO_L3GD20H): { + performL3gTest(gyro1L3gd20ChipSelect); + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + 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 */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - /* Adapt accordingly */ - if(mgmId != mgm1Rm3100ChipSelect and mgmId != mgm3Rm3100ChipSelect) { - sif::warning << "SpiTestClass::performRm3100Test: Invalid MGM ID!" << std::endl; - } - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = mgmId; - if(chipSelectPin == mgm1Rm3100ChipSelect) { - currentGpioId = gpioIds::MGM_1_RM3100_CS; - } - else { - currentGpioId = gpioIds::MGM_3_RM3100_CS; - } - uint32_t rm3100speed = 976'000; - uint8_t rm3100revidReg = 0x36; - spi::SpiModes rm3100mode = spi::SpiModes::MODE_3; + /* Adapt accordingly */ + if (mgmId != mgm1Rm3100ChipSelect and mgmId != mgm3Rm3100ChipSelect) { + sif::warning << "SpiTestClass::performRm3100Test: Invalid MGM ID!" << std::endl; + } + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = mgmId; + if (chipSelectPin == mgm1Rm3100ChipSelect) { + currentGpioId = gpioIds::MGM_1_RM3100_CS; + } else { + currentGpioId = gpioIds::MGM_3_RM3100_CS; + } + uint32_t rm3100speed = 976'000; + uint8_t rm3100revidReg = 0x36; + spi::SpiModes rm3100mode = spi::SpiModes::MODE_3; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, rm3100mode, rm3100speed); - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, rm3100mode, rm3100speed); + uint8_t revId = readRegister(fileDescriptor, currentGpioId, rm3100revidReg); + sif::info << "SpiTestClass::performRm3100Test: Revision ID 0b" << std::bitset<8>(revId) + << std::endl; - uint8_t revId = readRegister(fileDescriptor, currentGpioId, rm3100revidReg); - 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(cmmRegister) << std::dec << 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(cmmRegister) << std::dec << std::endl; + /* Read the cycle count registers */ + uint8_t cycleCountsRaw[6]; + readMultipleRegisters(fileDescriptor, currentGpioId, 0x04, cycleCountsRaw, 6); - /* Read the cycle count registers */ - uint8_t cycleCountsRaw[6]; - readMultipleRegisters(fileDescriptor, currentGpioId, 0x04, cycleCountsRaw, 6); + uint16_t cycleCountX = cycleCountsRaw[0] << 8 | cycleCountsRaw[1]; + uint16_t cycleCountY = cycleCountsRaw[2] << 8 | cycleCountsRaw[3]; + uint16_t cycleCountZ = cycleCountsRaw[4] << 8 | cycleCountsRaw[5]; - uint16_t cycleCountX = cycleCountsRaw[0] << 8 | cycleCountsRaw[1]; - uint16_t cycleCountY = cycleCountsRaw[2] << 8 | cycleCountsRaw[3]; - uint16_t cycleCountZ = cycleCountsRaw[4] << 8 | cycleCountsRaw[5]; + sif::info << "Cycle count X: " << cycleCountX << std::endl; + sif::info << "Cycle count Y: " << cycleCountY << std::endl; + sif::info << "Cycle count z: " << cycleCountZ << std::endl; - sif::info << "Cycle count X: " << cycleCountX << std::endl; - sif::info << "Cycle count Y: " << cycleCountY << std::endl; - sif::info << "Cycle count z: " << cycleCountZ << std::endl; - - writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96); - uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); - sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << - std::hex << "0x" << static_cast(tmrcReg) << std::dec << std::endl; + writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96); + uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); + sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << std::hex << "0x" + << static_cast(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; + /* This means that data is not ready */ + if ((statusReg & 0b1000'0000) == 0) { + sif::warning << "SpiTestClass::performRm3100Test: Data not ready!" << 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; - /* This means that data is not ready */ - if((statusReg & 0b1000'0000) == 0) { - sif::warning << "SpiTestClass::performRm3100Test: Data not ready!" << std::endl; - TaskFactory::delayTask(10); - uint8_t statusReg = readRm3100Register(fileDescriptor, currentGpioId, 0x34); - if((statusReg & 0b1000'0000) == 0) { - return; - } + if ((statusReg & 0b1000'0000) == 0) { + return; } + } - uint32_t rm3100DefaultCycleCout = 0xC8; - /* Gain scales lineary with cycle count and is 38 for cycle count 100 */ - float rm3100Gain = rm3100DefaultCycleCout / 100.0 * 38.0; - float scaleFactor = 1 / rm3100Gain; - uint8_t rawValues[9]; - readMultipleRegisters(fileDescriptor, currentGpioId, 0x24, rawValues, 9); + uint32_t rm3100DefaultCycleCout = 0xC8; + /* Gain scales lineary with cycle count and is 38 for cycle count 100 */ + float rm3100Gain = rm3100DefaultCycleCout / 100.0 * 38.0; + float scaleFactor = 1 / rm3100Gain; + uint8_t rawValues[9]; + readMultipleRegisters(fileDescriptor, currentGpioId, 0x24, rawValues, 9); - /* The sensor generates 24 bit signed values */ - int32_t rawX = ((rawValues[0] << 24) | (rawValues[1] << 16) | (rawValues[2] << 8)) >> 8; - int32_t rawY = ((rawValues[3] << 24) | (rawValues[4] << 16) | (rawValues[5] << 8)) >> 8; - int32_t rawZ = ((rawValues[6] << 24) | (rawValues[7] << 16) | (rawValues[8] << 8)) >> 8; + /* The sensor generates 24 bit signed values */ + int32_t rawX = ((rawValues[0] << 24) | (rawValues[1] << 16) | (rawValues[2] << 8)) >> 8; + int32_t rawY = ((rawValues[3] << 24) | (rawValues[4] << 16) | (rawValues[5] << 8)) >> 8; + int32_t rawZ = ((rawValues[6] << 24) | (rawValues[7] << 16) | (rawValues[8] << 8)) >> 8; - float fieldStrengthX = rawX * scaleFactor; - float fieldStrengthY = rawY * scaleFactor; - float fieldStrengthZ = rawZ * scaleFactor; + float fieldStrengthX = rawX * scaleFactor; + float fieldStrengthY = rawY * scaleFactor; + float fieldStrengthZ = rawZ * scaleFactor; - sif::info << "RM3100 measured field strengths in microtesla:" << std::endl; - sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl; - sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl; - sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl; + sif::info << "RM3100 measured field strengths in microtesla:" << std::endl; + sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl; + sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl; + sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl; } void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) { - /* Configure all SPI chip selects and pull them high */ - acsInit(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - /* Adapt accordingly */ - if(lis3Id != mgm0Lis3mdlChipSelect and lis3Id != mgm2Lis3mdlChipSelect) { - sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; - } - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = lis3Id; - uint8_t whoAmIReg = 0b0000'1111; - uint8_t whoAmIRegExpectedVal = 0b0011'1101; - if(chipSelectPin == mgm0Lis3mdlChipSelect) { - currentGpioId = gpioIds::MGM_0_LIS3_CS; - } - else { - currentGpioId = gpioIds::MGM_2_LIS3_CS; - } - uint32_t spiSpeed = 10'000'000; - spi::SpiModes spiMode = spi::SpiModes::MODE_0; + /* Adapt accordingly */ + if (lis3Id != mgm0Lis3mdlChipSelect and lis3Id != mgm2Lis3mdlChipSelect) { + sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; + } + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = lis3Id; + uint8_t whoAmIReg = 0b0000'1111; + uint8_t whoAmIRegExpectedVal = 0b0011'1101; + if (chipSelectPin == mgm0Lis3mdlChipSelect) { + currentGpioId = gpioIds::MGM_0_LIS3_CS; + } else { + currentGpioId = gpioIds::MGM_2_LIS3_CS; + } + uint32_t spiSpeed = 10'000'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_0; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - 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; - if(whoAmIRegVal != whoAmIRegExpectedVal) { - sif::warning << "SpiTestClass::performLis3MdlTest: WHO AM I register invalid!" - << std::endl; - } + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + 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; + if (whoAmIRegVal != whoAmIRegExpectedVal) { + 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(); + /* Configure all SPI chip selects and pull them high */ + acsInit(); - gpioId_t currentGpioId = 0; - uint8_t chipSelectPin = l3gId; - uint8_t whoAmIReg = 0b0000'1111; - uint8_t whoAmIRegExpectedVal = 0b1101'0111; + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = l3gId; + uint8_t whoAmIReg = 0b0000'1111; + uint8_t whoAmIRegExpectedVal = 0b1101'0111; - if(chipSelectPin == gyro1L3gd20ChipSelect) { - currentGpioId = gpioIds::GYRO_1_L3G_CS; - } - else { - currentGpioId = gpioIds::GYRO_3_L3G_CS; - } - uint32_t spiSpeed = 3'900'000; - spi::SpiModes spiMode = spi::SpiModes::MODE_3; + if (chipSelectPin == gyro1L3gd20ChipSelect) { + currentGpioId = gpioIds::GYRO_1_L3G_CS; + } else { + currentGpioId = gpioIds::GYRO_3_L3G_CS; + } + uint32_t spiSpeed = 3'900'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_3; #ifdef RASPBERRY_PI - std::string deviceName = "/dev/spidev0.0"; + std::string deviceName = "/dev/spidev0.0"; #else - std::string deviceName = "/dev/spidev2.0"; + std::string deviceName = "/dev/spidev2.0"; #endif - int fileDescriptor = 0; + int fileDescriptor = 0; - UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface"); - if(fileHelper.getOpenResult()) { - sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" - << std::endl; - return; - } - 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; - if(whoAmIRegVal != whoAmIRegExpectedVal) { - sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" << - std::endl; + UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); + if (fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + 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; + if (whoAmIRegVal != whoAmIRegExpectedVal) { + sif::warning << "SpiTestClass::performL3gTest: Read WHO AM I register invalid!" << std::endl; + } + + uint8_t ctrlReg1Addr = 0b0010'0000; + { + uint8_t commandRegs[5]; + commandRegs[0] = 0b0000'1111; + commandRegs[1] = 0x0; + commandRegs[2] = 0x0; + /* Configure big endian data format */ + commandRegs[3] = 0b0100'0000; + commandRegs[4] = 0x0; + writeMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, commandRegs, + sizeof(commandRegs)); + uint8_t readRegs[5]; + 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(idx + 1) << " not equal to configured value" << std::endl; + } } + } - uint8_t ctrlReg1Addr = 0b0010'0000; - { - uint8_t commandRegs[5]; - commandRegs[0] = 0b0000'1111; - commandRegs[1] = 0x0; - commandRegs[2] = 0x0; - /* Configure big endian data format */ - commandRegs[3] = 0b0100'0000; - commandRegs[4] = 0x0; - writeMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, commandRegs, - sizeof(commandRegs)); - uint8_t readRegs[5]; - 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(idx + 1) << " not equal to configured value" << std::endl; - } - } - } + uint8_t readOutBuffer[14]; + readMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readOutBuffer, + sizeof(readOutBuffer)); - uint8_t readOutBuffer[14]; - readMultipleStmRegisters(fileDescriptor, currentGpioId, ctrlReg1Addr, readOutBuffer, - sizeof(readOutBuffer)); + uint8_t statusReg = readOutBuffer[7]; + sif::info << "SpiTestClass::performL3gTest: Status Register 0b" << std::bitset<8>(statusReg) + << std::endl; - uint8_t statusReg = readOutBuffer[7]; - sif::info << "SpiTestClass::performL3gTest: Status Register 0b" << - std::bitset<8>(statusReg) << std::endl; + uint16_t l3gRange = 245; + float scaleFactor = static_cast(l3gRange) / INT16_MAX; + /* The sensor spits out little endian */ + int16_t angVelocRawX = (readOutBuffer[8] << 8) | readOutBuffer[9]; + int16_t angVelocRawY = (readOutBuffer[10] << 8) | readOutBuffer[11]; + int16_t angVelocRawZ = (readOutBuffer[12] << 8) | readOutBuffer[13]; - uint16_t l3gRange = 245; - float scaleFactor = static_cast(l3gRange) / INT16_MAX; - /* The sensor spits out little endian */ - int16_t angVelocRawX = (readOutBuffer[8] << 8) | readOutBuffer[9]; - int16_t angVelocRawY = (readOutBuffer[10] << 8) | readOutBuffer[11]; - int16_t angVelocRawZ = (readOutBuffer[12] << 8) | readOutBuffer[13]; - - float angVelocX = scaleFactor * angVelocRawX; - float angVelocY = scaleFactor * angVelocRawY; - float angVelocZ = scaleFactor * angVelocRawZ; - - sif::info << "Angular velocities for the L3GD20H in degrees per second:" << std::endl; - sif::info << "X: " << angVelocX << std::endl; - sif::info << "Y: " << angVelocY << std::endl; - sif::info << "Z: " << angVelocZ << std::endl; + float angVelocX = scaleFactor * angVelocRawX; + float angVelocY = scaleFactor * angVelocRawY; + float angVelocZ = scaleFactor * angVelocRawZ; + sif::info << "Angular velocities for the L3GD20H in degrees per second:" << std::endl; + sif::info << "X: " << angVelocX << std::endl; + sif::info << "Y: " << angVelocY << std::endl; + sif::info << "Z: " << angVelocZ << std::endl; } void SpiTestClass::acsInit() { - GpioCookie* gpioCookie = new GpioCookie(); + GpioCookie *gpioCookie = new GpioCookie(); #ifdef RASPBERRY_PI - GpiodRegularByChip* gpio = nullptr; - std::string rpiGpioName = "gpiochip0"; - gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", - gpio::DIR_OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); + GpiodRegularByChip *gpio = nullptr; + std::string rpiGpioName = "gpiochip0"; + 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); - gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); + 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); - gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + 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); - gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + 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); - gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + 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); - gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); + 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); - gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + 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); - 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); - 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); + GpiodRegularByLineName *gpio = nullptr; + 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); + 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); - 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); - 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); - gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + 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); + 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); + gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - // Enable pins must be pulled low for regular operations - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::DIR_OUT, - gpio::LOW); - gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::DIR_OUT, - gpio::LOW); - gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); + // Enable pins must be pulled low for regular operations + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_0_ENABLE", gpio::DIR_OUT, + gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + gpio = new GpiodRegularByLineName(q7s::gpioNames::GYRO_0_ENABLE, "GYRO_2_ENABLE", gpio::DIR_OUT, + gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); #endif - if (gpioIF != nullptr) { - gpioIF->addGpios(gpioCookie); - } + if (gpioIF != nullptr) { + gpioIF->addGpios(gpioCookie); + } } void SpiTestClass::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) { - int mode_test = SPI_MODE_3; - int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &mode_test);//reinterpret_cast(&mode)); - if(retval != 0) { - utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); - } + int mode_test = SPI_MODE_3; + int retval = ioctl(spiFd, SPI_IOC_WR_MODE, &mode_test); // reinterpret_cast(&mode)); + if (retval != 0) { + utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); + } - retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); - if(retval != 0) { - utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); - } + retval = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); + if (retval != 0) { + utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); + } } void SpiTestClass::writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value) { - spiTransferStruct.len = 2; - sendBuffer[0] = reg; - sendBuffer[1] = value; + spiTransferStruct.len = 2; + sendBuffer[0] = reg; + sendBuffer[1] = value; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::writeRegister: Write failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::writeRegister: Write failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } } void SpiTestClass::writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, - bool autoIncrement) { - if(autoIncrement) { - reg |= STM_AUTO_INCR_MASK; - } - writeRegister(fd, chipSelect, reg, value); + bool autoIncrement) { + if (autoIncrement) { + reg |= STM_AUTO_INCR_MASK; + } + writeRegister(fd, chipSelect, reg, value); } void SpiTestClass::writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, - uint8_t *values, size_t len) { - if(values == nullptr) { - return; - } - - reg |= STM_AUTO_INCR_MASK; - /* Clear read mask */ - reg &= ~STM_READ_MASK; - writeMultipleRegisters(fd, chipSelect, reg, values, len); + uint8_t *values, size_t len) { + if (values == nullptr) { + return; + } + reg |= STM_AUTO_INCR_MASK; + /* 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) { - if(values == nullptr) { - return; - } +void SpiTestClass::writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *values, + size_t len) { + if (values == nullptr) { + return; + } - sendBuffer[0] = reg; - std::memcpy(sendBuffer.data() + 1, values, len); - spiTransferStruct.len = len + 1; + sendBuffer[0] = reg; + std::memcpy(sendBuffer.data() + 1, values, len); + spiTransferStruct.len = len + 1; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } } uint8_t SpiTestClass::readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg) { - return readStmRegister(fd, chipSelect, reg, false); + return readStmRegister(fd, chipSelect, reg, false); } - -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); +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); } void SpiTestClass::readMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *reply, - size_t len) { - if(reply == nullptr) { - return; - } + size_t len) { + if (reply == nullptr) { + return; + } - spiTransferStruct.len = len + 1; - sendBuffer[0] = reg | STM_READ_MASK; + spiTransferStruct.len = len + 1; + sendBuffer[0] = reg | STM_READ_MASK; - for(uint8_t idx = 0; idx < len ; idx ++) { - sendBuffer[idx + 1] = 0; - } + for (uint8_t idx = 0; idx < len; idx++) { + sendBuffer[idx + 1] = 0; + } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } - std::memcpy(reply, recvBuffer.data() + 1, len); + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } + std::memcpy(reply, recvBuffer.data() + 1, len); } uint8_t SpiTestClass::readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, - bool autoIncrement) { - reg |= STM_READ_MASK; - if(autoIncrement) { - reg |= STM_AUTO_INCR_MASK; - } - return readRegister(fd, chipSelect, reg); + bool autoIncrement) { + reg |= STM_READ_MASK; + if (autoIncrement) { + reg |= STM_AUTO_INCR_MASK; + } + return readRegister(fd, chipSelect, reg); } - uint8_t SpiTestClass::readRegister(int fd, gpioId_t chipSelect, uint8_t reg) { - spiTransferStruct.len = 2; - sendBuffer[0] = reg; - sendBuffer[1] = 0; + spiTransferStruct.len = 2; + sendBuffer[0] = reg; + sendBuffer[1] = 0; - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullLow(chipSelect); - } - int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); - if(retval < 0) { - utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); - } - if(gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { - gpioIF->pullHigh(chipSelect); - } - return recvBuffer[1]; + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullLow(chipSelect); + } + int retval = ioctl(fd, SPI_IOC_MESSAGE(1), &spiTransferStruct); + if (retval < 0) { + utility::handleIoctlError("SpiTestClass::readRegister: Read failed"); + } + if (gpioIF != nullptr and chipSelect != gpio::NO_GPIO) { + gpioIF->pullHigh(chipSelect); + } + return recvBuffer[1]; } diff --git a/linux/boardtest/SpiTestClass.h b/linux/boardtest/SpiTestClass.h index ffd56dd1..5df8cafb 100644 --- a/linux/boardtest/SpiTestClass.h +++ b/linux/boardtest/SpiTestClass.h @@ -13,83 +13,78 @@ #include -class SpiTestClass: public TestTask { -public: - enum TestModes { - NONE, - MGM_LIS3MDL, - MGM_RM3100, - GYRO_L3GD20H, - }; +class SpiTestClass : public TestTask { + public: + enum TestModes { + NONE, + MGM_LIS3MDL, + MGM_RM3100, + GYRO_L3GD20H, + }; - TestModes testMode; + TestModes testMode; - SpiTestClass(object_id_t objectId, GpioIF* gpioIF); + SpiTestClass(object_id_t objectId, GpioIF* gpioIF); - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; -private: + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; - GpioIF* gpioIF; + private: + GpioIF* gpioIF; - std::array recvBuffer; - std::array sendBuffer; - struct spi_ioc_transfer spiTransferStruct = {}; + std::array recvBuffer; + std::array sendBuffer; + struct spi_ioc_transfer spiTransferStruct = {}; - void performRm3100Test(uint8_t mgmId); - void performLis3MdlTest(uint8_t lis3Id); - void performL3gTest(uint8_t l3gId); + void performRm3100Test(uint8_t mgmId); + void performLis3MdlTest(uint8_t lis3Id); + void performL3gTest(uint8_t l3gId); - /* ACS board specific code which pulls all GPIOs high */ - void acsInit(); + /* ACS board specific code which pulls all GPIOs high */ + void acsInit(); - /* ACS board specific variables */ + /* ACS board specific variables */ #ifdef RASPBERRY_PI - uint8_t mgm0Lis3mdlChipSelect = gpio::MGM_0_BCM_PIN; - uint8_t mgm1Rm3100ChipSelect = gpio::MGM_1_BCM_PIN; - uint8_t mgm2Lis3mdlChipSelect = gpio::MGM_2_BCM_PIN; - uint8_t mgm3Rm3100ChipSelect = gpio::MGM_3_BCM_PIN; + uint8_t mgm0Lis3mdlChipSelect = gpio::MGM_0_BCM_PIN; + uint8_t mgm1Rm3100ChipSelect = gpio::MGM_1_BCM_PIN; + uint8_t mgm2Lis3mdlChipSelect = gpio::MGM_2_BCM_PIN; + uint8_t mgm3Rm3100ChipSelect = gpio::MGM_3_BCM_PIN; - uint8_t gyro0AdisChipSelect = gpio::GYRO_0_BCM_PIN; - uint8_t gyro1L3gd20ChipSelect = gpio::GYRO_1_BCM_PIN; - uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; - uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; + uint8_t gyro0AdisChipSelect = gpio::GYRO_0_BCM_PIN; + uint8_t gyro1L3gd20ChipSelect = gpio::GYRO_1_BCM_PIN; + uint8_t gyro2AdisChipSelect = gpio::GYRO_2_BCM_PIN; + uint8_t gyro3L3gd20ChipSelect = gpio::GYRO_3_BCM_PIN; #else - uint8_t mgm0Lis3mdlChipSelect = 0; - uint8_t mgm1Rm3100ChipSelect = 0; - uint8_t gyro0AdisResetLine = 0; - uint8_t gyro0AdisChipSelect = 0; - uint8_t gyro1L3gd20ChipSelect = 0; - uint8_t gyro2L3gd20ChipSelect = 0; - uint8_t mgm2Lis3mdlChipSelect = 0; - uint8_t mgm3Rm3100ChipSelect = 0; + uint8_t mgm0Lis3mdlChipSelect = 0; + uint8_t mgm1Rm3100ChipSelect = 0; + uint8_t gyro0AdisResetLine = 0; + uint8_t gyro0AdisChipSelect = 0; + uint8_t gyro1L3gd20ChipSelect = 0; + uint8_t gyro2L3gd20ChipSelect = 0; + uint8_t mgm2Lis3mdlChipSelect = 0; + uint8_t mgm3Rm3100ChipSelect = 0; #endif - static constexpr uint8_t STM_READ_MASK = 0b1000'0000; - static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK; - static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; + static constexpr uint8_t STM_READ_MASK = 0b1000'0000; + static constexpr uint8_t RM3100_READ_MASK = STM_READ_MASK; + static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; - void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); + void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); - void writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, - bool autoIncrement); - void writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, - size_t len); - void writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t *values, - size_t len); - void writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value); - - uint8_t readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg); - uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); - 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 writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, + bool autoIncrement); + void writeMultipleStmRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, + size_t len); + void writeMultipleRegisters(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t* values, + size_t len); + void writeRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value); + uint8_t readRm3100Register(int fd, gpioId_t chipSelect, uint8_t reg); + uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); + 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); }; - - - #endif /* LINUX_BOARDTEST_SPITESTCLASS_H_ */ diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index e69f0e5f..9b20ad13 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -5,110 +5,107 @@ #include "q7sConfig.h" #endif -#include "fsfw/serviceinterface/ServiceInterface.h" +#include // Error integer and strerror() function +#include // Contains file controls like O_RDWR +#include // write(), read(), close() +#include "fsfw/serviceinterface/ServiceInterface.h" #include "lwgps/lwgps.h" -#include // Contains file controls like O_RDWR -#include // Error integer and strerror() function -#include // write(), read(), close() +#define GPS_REPLY_WIRETAPPING 0 -#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 - int result = lwgps_init(&gpsData); - if(result == 0) { - sif::warning << "lwgps_init error: " << result << std::endl; - } + int result = lwgps_init(&gpsData); + if (result == 0) { + sif::warning << "lwgps_init error: " << result << std::endl; + } - /* Get file descriptor */ - serialPort = open("/dev/serial0", O_RDWR); - if(serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - } - /* Setting up UART parameters */ - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - // Use canonical mode for GPS device - tty.c_lflag |= ICANON; - tty.c_lflag &= ~ECHO; // Disable echo - tty.c_lflag &= ~ECHOE; // Disable erasure - 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_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 + /* Get file descriptor */ + serialPort = open("/dev/serial0", O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + /* Setting up UART parameters */ + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + // Use canonical mode for GPS device + tty.c_lflag |= ICANON; + tty.c_lflag &= ~ECHO; // Disable echo + tty.c_lflag &= ~ECHOE; // Disable erasure + 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_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 - // Non-blocking mode - tty.c_cc[VTIME] = 0; - tty.c_cc[VMIN] = 0; + // Non-blocking mode + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); - cfsetospeed(&tty, B9600); - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - 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); + cfsetispeed(&tty, B9600); + cfsetospeed(&tty, B9600); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + 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); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performOneShotAction() { #if RPI_TEST_GPS_DEVICE == 1 #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performPeriodicAction() { #if RPI_TEST_GPS_DEVICE == 1 - int bytesRead = 0; - do { - bytesRead = read(serialPort, - reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if(bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << - errno << ", " << strerror(errno) << "]" << std::endl; - break; - } - else if(bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: " - "recv buffer might not be large enough" << std::endl; - } - else if(bytesRead > 0) { - // pass data to lwgps for processing + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno + << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: " + "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; + 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; - } - recvCnt++; - if(recvCnt == 6) { - recvCnt = 0; - sif::info << "GPS Data" << std::endl; - // Print messages - printf("Valid status: %d\n", gpsData.is_valid); - printf("Latitude: %f degrees\n", gpsData.latitude); - printf("Longitude: %f degrees\n", gpsData.longitude); - printf("Altitude: %f meters\n", gpsData.altitude); - } - } - } while(bytesRead > 0); + int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); + if (result == 0) { + sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl; + } + recvCnt++; + if (recvCnt == 6) { + recvCnt = 0; + sif::info << "GPS Data" << std::endl; + // Print messages + printf("Valid status: %d\n", gpsData.is_valid); + printf("Latitude: %f degrees\n", gpsData.latitude); + printf("Longitude: %f degrees\n", gpsData.longitude); + printf("Altitude: %f meters\n", gpsData.altitude); + } + } + } while (bytesRead > 0); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index aeb2c396..f32d909d 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -1,27 +1,27 @@ #ifndef LINUX_BOARDTEST_UARTTESTCLASS_H_ #define LINUX_BOARDTEST_UARTTESTCLASS_H_ -#include "test/testtasks/TestTask.h" -#include "lwgps/lwgps.h" +#include // Contains POSIX terminal control definitions #include -#include // Contains POSIX terminal control definitions -class UartTestClass: public TestTask { -public: - UartTestClass(object_id_t objectId); +#include "lwgps/lwgps.h" +#include "test/testtasks/TestTask.h" - ReturnValue_t initialize() override; - ReturnValue_t performOneShotAction() override; - ReturnValue_t performPeriodicAction() override; -private: +class UartTestClass : public TestTask { + public: + UartTestClass(object_id_t objectId); - lwgps_t gpsData = {}; - struct termios tty = {}; - int serialPort = 0; - std::array recBuf; - uint8_t recvCnt = 0; + ReturnValue_t initialize() override; + ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; + private: + lwgps_t gpsData = {}; + struct termios tty = {}; + int serialPort = 0; + std::array recBuf; + uint8_t recvCnt = 0; }; #endif /* LINUX_BOARDTEST_UARTTESTCLASS_H_ */ diff --git a/linux/csp/CspComIF.cpp b/linux/csp/CspComIF.cpp index 07fe63d3..fa372d4d 100644 --- a/linux/csp/CspComIF.cpp +++ b/linux/csp/CspComIF.cpp @@ -1,259 +1,246 @@ #include "CspComIF.h" -#include "CspCookie.h" -#include #include #include +#include -CspComIF::CspComIF(object_id_t objectId) : - SystemObject(objectId) { -} +#include "CspCookie.h" -CspComIF::~CspComIF() { -} +CspComIF::CspComIF(object_id_t objectId) : SystemObject(objectId) {} -ReturnValue_t CspComIF::initializeInterface(CookieIF *cookie) { - if(cookie == nullptr) { - return NULLPOINTER; - } +CspComIF::~CspComIF() {} - CspCookie* cspCookie = dynamic_cast(cookie); - if(cspCookie == nullptr) { - return NULLPOINTER; - } +ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) { + if (cookie == nullptr) { + return NULLPOINTER; + } - /* Perform CAN and CSP initialization only once */ - if(cspDeviceMap.empty()){ - sif::info << "Performing " << canInterface << " initialization.." << std::endl; + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == nullptr) { + return NULLPOINTER; + } - /* Define the memory to allocate for the CSP stack */ - 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) { - sif::error << "Failed to init CSP\r\n" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + /* Perform CAN and CSP initialization only once */ + if (cspDeviceMap.empty()) { + sif::info << "Performing " << canInterface << " initialization.." << std::endl; - int promisc = 0; // Set filter mode on - csp_iface_t *csp_if_ptr = &csp_if; - csp_if_ptr = csp_can_socketcan_init(canInterface, bitrate, promisc); - - /* Set default route and start router */ - uint8_t address = CSP_DEFAULT_ROUTE; - uint8_t netmask = 0; - 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; - return HasReturnvaluesIF::RETURN_FAILED; - } - - /* Start the route task */ - unsigned int task_stack_size = 500; - unsigned int priority = 0; - result = csp_route_start_task(task_stack_size, priority); - if(result != CSP_ERR_NONE){ - sif::error << "Failed to start csp route task" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - sif::info << canInterface << " initialized successfully" << std::endl; - } - - uint8_t cspAddress = cspCookie->getCspAddress(); - uint16_t maxReplyLength = cspCookie->getMaxReplyLength(); - if(cspDeviceMap.find(cspAddress) == cspDeviceMap.end()){ - /* Insert device information in CSP map */ - cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength)); - } - - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CspComIF::sendMessage(CookieIF *cookie, - const uint8_t * sendData, size_t sendLen) { - int result; - if(cookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - CspCookie* cspCookie = dynamic_cast (cookie); - if(cspCookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - - /* Extract csp port and bytes to query from command buffer */ - uint8_t cspPort; - uint16_t querySize = 0; - result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - uint8_t cspAddress = cspCookie->getCspAddress(); - switch(cspPort) { - case(Ports::CSP_PING): { - initiatePingRequest(cspAddress, querySize); - break; - } - case(Ports::CSP_REBOOT): { - csp_reboot(cspAddress); - break; - } - case(Ports::P60_PORT_GNDWDT_RESET): - 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); - if(result != HasReturnvaluesIF::RETURN_OK){ - return HasReturnvaluesIF::RETURN_FAILED; - } - replySize = querySize; - break; - } - default: - sif::error << "CspComIF: Invalid port specified" << std::endl; - break; - } - return HasReturnvaluesIF::RETURN_OK; -} - -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::readReceivedMessage(CookieIF *cookie, - uint8_t** buffer, size_t* size) { - if(cookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - CspCookie* cspCookie = dynamic_cast (cookie); - if(cspCookie == NULL){ - return HasReturnvaluesIF::RETURN_FAILED; - } - - uint8_t cspAddress = cspCookie->getCspAddress(); - - *buffer = cspDeviceMap[cspAddress].data(); - *size = replySize; - - return HasReturnvaluesIF::RETURN_OK; -} - -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; - vectorBufferIter iter = cspDeviceMap.find(cspAddress); - if(iter == cspDeviceMap.end()){ - sif::error << "CSP device with address " << cspAddress << " no found in" - << " device map" << std::endl; - } - uint8_t* replyBuffer = iter->second.data(); - - 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) { - sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp " - << "stack" << std::endl; - csp_close(conn); - return RETURN_FAILED; + /* Define the memory to allocate for the CSP stack */ + 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) { + sif::error << "Failed to init CSP\r\n" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - memcpy(commandPacket->data, cmdBuffer, cmdLen); - commandPacket->length = cmdLen; + int promisc = 0; // Set filter mode on + csp_iface_t* csp_if_ptr = &csp_if; + csp_if_ptr = csp_can_socketcan_init(canInterface, bitrate, promisc); - if (!csp_send(conn, commandPacket, timeout_ms)) { - csp_buffer_free(commandPacket); - sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; + /* Set default route and start router */ + uint8_t address = CSP_DEFAULT_ROUTE; + uint8_t netmask = 0; + 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; + return HasReturnvaluesIF::RETURN_FAILED; } - /* Return when no reply is expected */ - if (expectedSize == 0) { - return RETURN_OK; + /* Start the route task */ + unsigned int task_stack_size = 500; + unsigned int priority = 0; + result = csp_route_start_task(task_stack_size, priority); + if (result != CSP_ERR_NONE) { + sif::error << "Failed to start csp route task" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } + sif::info << canInterface << " initialized successfully" << std::endl; + } - csp_packet_t * reply; + uint8_t cspAddress = cspCookie->getCspAddress(); + uint16_t maxReplyLength = cspCookie->getMaxReplyLength(); + if (cspDeviceMap.find(cspAddress) == cspDeviceMap.end()) { + /* Insert device information in CSP map */ + cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength)); + } + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { + int result; + if (cookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + /* Extract csp port and bytes to query from command buffer */ + uint8_t cspPort; + uint16_t querySize = 0; + result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + uint8_t cspAddress = cspCookie->getCspAddress(); + switch (cspPort) { + case (Ports::CSP_PING): { + initiatePingRequest(cspAddress, querySize); + break; + } + case (Ports::CSP_REBOOT): { + csp_reboot(cspAddress); + break; + } + case (Ports::P60_PORT_GNDWDT_RESET): + 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); + if (result != HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_FAILED; + } + replySize = querySize; + break; + } + default: + sif::error << "CspComIF: Invalid port specified" << std::endl; + break; + } + return HasReturnvaluesIF::RETURN_OK; +} + +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::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { + if (cookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + CspCookie* cspCookie = dynamic_cast(cookie); + if (cspCookie == NULL) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + uint8_t cspAddress = cspCookie->getCspAddress(); + + *buffer = cspDeviceMap[cspAddress].data(); + *size = replySize; + + return HasReturnvaluesIF::RETURN_OK; +} + +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; + vectorBufferIter iter = cspDeviceMap.find(cspAddress); + if (iter == cspDeviceMap.end()) { + sif::error << "CSP device with address " << cspAddress << " no found in" + << " device map" << std::endl; + } + uint8_t* replyBuffer = iter->second.data(); + + 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) { + sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp " + << "stack" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + + memcpy(commandPacket->data, cmdBuffer, cmdLen); + commandPacket->length = cmdLen; + + if (!csp_send(conn, commandPacket, timeout_ms)) { + csp_buffer_free(commandPacket); + sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + + /* Return when no reply is expected */ + if (expectedSize == 0) { + return RETURN_OK; + } + + csp_packet_t* reply; + reply = csp_read(conn, timeout_ms); + if (reply == NULL) { + sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; + } + memcpy(replyBuffer, reply->data, reply->length); + expectedSize = expectedSize - reply->length; + bytesRead += reply->length; + csp_buffer_free(reply); + while (expectedSize > 0) { reply = csp_read(conn, timeout_ms); if (reply == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; + sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; + csp_close(conn); + return RETURN_FAILED; } - memcpy(replyBuffer, reply->data, reply->length); + if ((reply->length + bytesRead) > iter->second.size()) { + sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl; + csp_buffer_free(reply); + csp_close(conn); + return RETURN_FAILED; + } + memcpy(replyBuffer + bytesRead, reply->data, reply->length); expectedSize = expectedSize - reply->length; bytesRead += reply->length; csp_buffer_free(reply); - while (expectedSize > 0) { - reply = csp_read(conn, timeout_ms); - if (reply == NULL) { - sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl; - csp_close(conn); - return RETURN_FAILED; - } - if ((reply->length + bytesRead) > iter->second.size()) { - sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl; - csp_buffer_free(reply); - csp_close(conn); - return RETURN_FAILED; - } - memcpy(replyBuffer + bytesRead, reply->data, reply->length); - expectedSize = expectedSize - reply->length; - bytesRead += reply->length; - csp_buffer_free(reply); - } + } - if(expectedSize != 0){ - sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl; - sif::debug << "CspComIF::cspTransfer: Received bytes: " << bytesRead << std::endl; - csp_close(conn); - return RETURN_FAILED; - } + if (expectedSize != 0) { + sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl; + sif::debug << "CspComIF::cspTransfer: Received bytes: " << bytesRead << std::endl; + csp_close(conn); + return RETURN_FAILED; + } - csp_close(conn); + csp_close(conn); - return HasReturnvaluesIF::RETURN_OK; + 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); - 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); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "CspComIF: Failed to deserialize querySize from command " - << "buffer" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - 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); + 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); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "CspComIF: Failed to deserialize querySize from command " + << "buffer" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -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; - /* Store reply time in reply buffer * */ - uint8_t* replyBuffer = cspDeviceMap[cspAddress].data(); - memcpy(replyBuffer, &replyTime, sizeof(replyTime)); - replySize = sizeof(replyTime); +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; + /* Store reply time in reply buffer * */ + uint8_t* replyBuffer = cspDeviceMap[cspAddress].data(); + memcpy(replyBuffer, &replyTime, sizeof(replyTime)); + replySize = sizeof(replyTime); } diff --git a/linux/csp/CspComIF.h b/linux/csp/CspComIF.h index 4b8d323b..d36bbf4f 100644 --- a/linux/csp/CspComIF.h +++ b/linux/csp/CspComIF.h @@ -1,13 +1,13 @@ #ifndef LINUX_CSP_CSPCOMIF_H_ #define LINUX_CSP_CSPCOMIF_H_ +#include #include #include #include -#include -#include #include +#include /** * @brief This class serves as the communication interface to devices @@ -15,75 +15,65 @@ * in this implementation. * @author J. Meier */ -class CspComIF: public DeviceCommunicationIF, public SystemObject { -public: - CspComIF(object_id_t objectId); - virtual ~CspComIF(); +class CspComIF : public DeviceCommunicationIF, public SystemObject { + public: + CspComIF(object_id_t objectId); + virtual ~CspComIF(); - ReturnValue_t initializeInterface(CookieIF * cookie) 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 initializeInterface(CookieIF *cookie) 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; -private: + private: + /** + * @brief This function initiates the CSP transfer. + * + * @param cspAddress The CSP address of the target device. + * @param cspPort The port of the target device. + * @param timeout The timeout to wait for csp_send and csp_read + * functions. Specifies how long the functions wait + * for a successful operation. + * @param cmdBuffer The data to send. + * @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); - /** - * @brief This function initiates the CSP transfer. - * - * @param cspAddress The CSP address of the target device. - * @param cspPort The port of the target device. - * @param timeout The timeout to wait for csp_send and csp_read - * functions. Specifies how long the functions wait - * for a successful operation. - * @param cmdBuffer The data to send. - * @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 }; - 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; + using VectorBufferMap = std::unordered_map; + using vectorBufferIter = VectorBufferMap::iterator; + /* In this map assigns reply buffers to a CSP device */ + VectorBufferMap cspDeviceMap; - typedef uint8_t node_t; - using vectorBuffer = std::vector; - using VectorBufferMap = std::unordered_map; - using vectorBufferIter = VectorBufferMap::iterator; + uint16_t replySize = 0; - /* In this map assigns reply buffers to a CSP device */ - VectorBufferMap cspDeviceMap; + /* This is the CSP address of the OBC. */ + node_t cspOwnAddress = 1; - uint16_t replySize = 0; + /* Interface struct for csp protocol stack */ + csp_iface_t csp_if; - /* This is the CSP address of the OBC. */ - node_t cspOwnAddress = 1; + char canInterface[5] = "can0"; + int bitrate = 1000; - /* Interface struct for csp protocol stack */ - csp_iface_t csp_if; + /** + * @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); - char canInterface[5] = "can0"; - int bitrate = 1000; - - /** - * @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); - - /** - * @brief This function initiates the ping request. - */ - void initiatePingRequest(uint8_t cspAddress, uint16_t querySize); + /** + * @brief This function initiates the ping request. + */ + void initiatePingRequest(uint8_t cspAddress, uint16_t querySize); }; #endif /* LINUX_CSP_CSPCOMIF_H_ */ diff --git a/linux/csp/CspCookie.cpp b/linux/csp/CspCookie.cpp index 18cfabd2..39274908 100644 --- a/linux/csp/CspCookie.cpp +++ b/linux/csp/CspCookie.cpp @@ -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; } diff --git a/linux/csp/CspCookie.h b/linux/csp/CspCookie.h index 4514c257..e59f3d35 100644 --- a/linux/csp/CspCookie.h +++ b/linux/csp/CspCookie.h @@ -2,6 +2,7 @@ #define LINUX_CSP_CSPCOOKIE_H_ #include + #include /** @@ -9,19 +10,17 @@ * Protocol). * @author J. Meier */ -class CspCookie: public CookieIF { -public: +class CspCookie : public CookieIF { + public: + CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_); + virtual ~CspCookie(); - CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_); - virtual ~CspCookie(); + uint16_t getMaxReplyLength(); + uint8_t getCspAddress(); - uint16_t getMaxReplyLength(); - uint8_t getCspAddress(); - -private: - - uint16_t maxReplyLength; - uint8_t cspAddress; + private: + uint16_t maxReplyLength; + uint8_t cspAddress; }; #endif /* LINUX_CSP_CSPCOOKIE_H_ */ diff --git a/linux/devices/SolarArrayDeploymentHandler.cpp b/linux/devices/SolarArrayDeploymentHandler.cpp index eea546f6..fed3992b 100644 --- a/linux/devices/SolarArrayDeploymentHandler.cpp +++ b/linux/devices/SolarArrayDeploymentHandler.cpp @@ -1,202 +1,209 @@ #include "SolarArrayDeploymentHandler.h" -#include #include - -#include +#include #include #include - +#include 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; - } + if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { + handleStateMachine(); return RETURN_OK; + } + return RETURN_OK; } ReturnValue_t SolarArrayDeploymentHandler::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - gpioInterface = ObjectManager::instance()->get(gpioDriverId); - if (gpioInterface == nullptr) { - sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." - << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + gpioInterface = ObjectManager::instance()->get(gpioDriverId); + if (gpioInterface == nullptr) { + sif::error << "SolarArrayDeploymentHandler::initialize: Invalid Gpio interface." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); - if (result != RETURN_OK) { - sif::error << "SolarArrayDeploymentHandler::initialize: Failed to initialize Gpio interface" - << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); + if (result != RETURN_OK) { + sif::error << "SolarArrayDeploymentHandler::initialize: Failed to initialize Gpio interface" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if (mainLineSwitcherObjectId != objects::NO_OBJECT) { - mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); - if (mainLineSwitcher == nullptr) { - sif::error - << "SolarArrayDeploymentHandler::initialize: Main line switcher failed to fetch object" - << "from object ID." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + if (mainLineSwitcherObjectId != objects::NO_OBJECT) { + mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); + if (mainLineSwitcher == nullptr) { + sif::error + << "SolarArrayDeploymentHandler::initialize: Main line switcher failed to fetch object" + << "from object ID." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; } + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - return RETURN_OK; + return RETURN_OK; } void SolarArrayDeploymentHandler::handleStateMachine() { - switch (stateMachine) { + switch (stateMachine) { case WAIT_ON_DELOYMENT_COMMAND: - readCommandQueue(); - break; + readCommandQueue(); + break; case SWITCH_8V_ON: - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); - mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - stateMachine = WAIT_ON_8V_SWITCH; - break; + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); + mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + stateMachine = WAIT_ON_8V_SWITCH; + break; case WAIT_ON_8V_SWITCH: - performWaitOn8VActions(); - break; + performWaitOn8VActions(); + break; case SWITCH_DEPL_GPIOS: - switchDeploymentTransistors(); - break; + switchDeploymentTransistors(); + break; case WAIT_ON_DEPLOYMENT_FINISH: - handleDeploymentFinish(); - break; + handleDeploymentFinish(); + break; case WAIT_FOR_MAIN_SWITCH_OFF: - if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) { - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } else if (mainSwitchCountdown.hasTimedOut()) { - triggerEvent(MAIN_SWITCH_OFF_TIMEOUT); - sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main" - << " switch off" << std::endl; - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } - break; + if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_OFF) { + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + } else if (mainSwitchCountdown.hasTimedOut()) { + triggerEvent(MAIN_SWITCH_OFF_TIMEOUT); + sif::error << "SolarArrayDeploymentHandler::handleStateMachine: Failed to switch main" + << " switch off" << std::endl; + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + } + break; default: - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" << std::endl; - break; - } + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Invalid state" << std::endl; + break; + } } void SolarArrayDeploymentHandler::performWaitOn8VActions() { - if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) { - stateMachine = SWITCH_DEPL_GPIOS; - } else { - if (mainSwitchCountdown.hasTimedOut()) { - triggerEvent(MAIN_SWITCH_ON_TIMEOUT); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - MAIN_SWITCH_TIMEOUT_FAILURE); - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - } + if (mainLineSwitcher->getSwitchState(mainLineSwitch) == PowerSwitchIF::SWITCH_ON) { + stateMachine = SWITCH_DEPL_GPIOS; + } else { + if (mainSwitchCountdown.hasTimedOut()) { + triggerEvent(MAIN_SWITCH_ON_TIMEOUT); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, + MAIN_SWITCH_TIMEOUT_FAILURE); + stateMachine = WAIT_ON_DELOYMENT_COMMAND; } + } } void SolarArrayDeploymentHandler::switchDeploymentTransistors() { - ReturnValue_t result = RETURN_OK; - result = gpioInterface->pullHigh(deplSA1); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " 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); - 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; - stateMachine = WAIT_ON_DELOYMENT_COMMAND; - triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); - actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, - SWITCHING_DEPL_SA2_FAILED); - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - deploymentCountdown.setTimeout(burnTimeMs); - stateMachine = WAIT_ON_DEPLOYMENT_FINISH; + ReturnValue_t result = RETURN_OK; + result = gpioInterface->pullHigh(deplSA1); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " 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); + 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; + stateMachine = WAIT_ON_DELOYMENT_COMMAND; + triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); + actionHelper.finish(false, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, SWITCHING_DEPL_SA2_FAILED); + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } + deploymentCountdown.setTimeout(burnTimeMs); + stateMachine = WAIT_ON_DEPLOYMENT_FINISH; } void SolarArrayDeploymentHandler::handleDeploymentFinish() { - ReturnValue_t result = RETURN_OK; - if (deploymentCountdown.hasTimedOut()) { - actionHelper.finish(true, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, RETURN_OK); - result = gpioInterface->pullLow(deplSA1); - if (result != RETURN_OK) { - sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" - " 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; - } - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - stateMachine = WAIT_FOR_MAIN_SWITCH_OFF; + ReturnValue_t result = RETURN_OK; + if (deploymentCountdown.hasTimedOut()) { + actionHelper.finish(true, rememberCommanderId, DEPLOY_SOLAR_ARRAYS, RETURN_OK); + result = gpioInterface->pullLow(deplSA1); + if (result != RETURN_OK) { + sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" + " 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; + } + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + stateMachine = WAIT_FOR_MAIN_SWITCH_OFF; + } } void SolarArrayDeploymentHandler::readCommandQueue() { - CommandMessage command; - ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + CommandMessage command; + ReturnValue_t result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { - return; - } + result = actionHelper.handleActionMessage(&command); + if (result == RETURN_OK) { + return; + } } ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId, - 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" - << "waiting-on-command-state" << std::endl; - return DEPLOYMENT_ALREADY_EXECUTING; - } - if (actionId != DEPLOY_SOLAR_ARRAYS) { - sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command" - << std::endl; - result = COMMAND_NOT_SUPPORTED; - } else { - stateMachine = SWITCH_8V_ON; - rememberCommanderId = commandedBy; - result = RETURN_OK; - } - return result; + 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" + << "waiting-on-command-state" << std::endl; + return DEPLOYMENT_ALREADY_EXECUTING; + } + if (actionId != DEPLOY_SOLAR_ARRAYS) { + sif::error << "SolarArrayDeploymentHandler::executeAction: Received invalid command" + << std::endl; + result = COMMAND_NOT_SUPPORTED; + } else { + stateMachine = SWITCH_8V_ON; + rememberCommanderId = commandedBy; + result = RETURN_OK; + } + return result; } MessageQueueId_t SolarArrayDeploymentHandler::getCommandQueue() const { - return commandQueue->getId(); + return commandQueue->getId(); } diff --git a/linux/devices/SolarArrayDeploymentHandler.h b/linux/devices/SolarArrayDeploymentHandler.h index 5e573128..90380ae2 100644 --- a/linux/devices/SolarArrayDeploymentHandler.h +++ b/linux/devices/SolarArrayDeploymentHandler.h @@ -1,15 +1,16 @@ #ifndef MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ #define MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include #include #include + #include /** @@ -17,142 +18,139 @@ * * @author J. Meier */ -class SolarArrayDeploymentHandler: public ExecutableObjectIF, - public SystemObject, - public HasReturnvaluesIF, - public HasActionsIF { -public: +class SolarArrayDeploymentHandler : public ExecutableObjectIF, + public SystemObject, + public HasReturnvaluesIF, + public HasActionsIF { + public: + static const DeviceCommandId_t DEPLOY_SOLAR_ARRAYS = 0x5; - static const DeviceCommandId_t DEPLOY_SOLAR_ARRAYS = 0x5; + /** + * @brief constructor + * + * @param setObjectId The object id of the SolarArrayDeploymentHandler. + * @param gpioDriverId The id of the gpio com if. + * @param gpioCookie GpioCookie holding information about the gpios used to switch the + * transistors. + * @param mainLineSwitcherObjectId The object id of the object responsible for switching + * the 8V power source. This is normally the PCDU. + * @param mainLineSwitch The id of the main line switch. This is defined in + * powerSwitcherList.h. + * @param deplSA1 gpioId of the GPIO controlling the deployment 1 transistor. + * @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor. + * @param burnTimeMs Time duration the power will be applied to the burn wires. + */ + 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); - /** - * @brief constructor - * - * @param setObjectId The object id of the SolarArrayDeploymentHandler. - * @param gpioDriverId The id of the gpio com if. - * @param gpioCookie GpioCookie holding information about the gpios used to switch the - * transistors. - * @param mainLineSwitcherObjectId The object id of the object responsible for switching - * the 8V power source. This is normally the PCDU. - * @param mainLineSwitch The id of the main line switch. This is defined in - * powerSwitcherList.h. - * @param deplSA1 gpioId of the GPIO controlling the deployment 1 transistor. - * @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor. - * @param burnTimeMs Time duration the power will be applied to the burn wires. - */ - 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); + virtual ~SolarArrayDeploymentHandler(); - virtual ~SolarArrayDeploymentHandler(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + virtual ReturnValue_t initialize() override; - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - virtual ReturnValue_t initialize() override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SA_DEPL_HANDLER; + static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t DEPLOYMENT_ALREADY_EXECUTING = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t MAIN_SWITCH_TIMEOUT_FAILURE = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t SWITCHING_DEPL_SA1_FAILED = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t SWITCHING_DEPL_SA2_FAILED = MAKE_RETURN_CODE(0xA4); -private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SA_DEPL_HANDLER; + static const Event MAIN_SWITCH_ON_TIMEOUT = MAKE_EVENT(0, severity::LOW); + static const Event MAIN_SWITCH_OFF_TIMEOUT = MAKE_EVENT(1, severity::LOW); + static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH); + static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH); + static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH); - static const uint8_t INTERFACE_ID = CLASS_ID::SA_DEPL_HANDLER; - static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t DEPLOYMENT_ALREADY_EXECUTING = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t MAIN_SWITCH_TIMEOUT_FAILURE = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t SWITCHING_DEPL_SA1_FAILED = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t SWITCHING_DEPL_SA2_FAILED = MAKE_RETURN_CODE(0xA4); + enum StateMachine { + WAIT_ON_DELOYMENT_COMMAND, + SWITCH_8V_ON, + WAIT_ON_8V_SWITCH, + SWITCH_DEPL_GPIOS, + WAIT_ON_DEPLOYMENT_FINISH, + WAIT_FOR_MAIN_SWITCH_OFF + }; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SA_DEPL_HANDLER; - static const Event MAIN_SWITCH_ON_TIMEOUT = MAKE_EVENT(0, severity::LOW); - static const Event MAIN_SWITCH_OFF_TIMEOUT = MAKE_EVENT(1, severity::LOW); - static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH); - static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH); - static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH); + StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND; + /** + * This countdown is used to check if the PCDU sets the 8V line on in the intended time. + */ + Countdown mainSwitchCountdown; - enum StateMachine { - WAIT_ON_DELOYMENT_COMMAND, - SWITCH_8V_ON, - WAIT_ON_8V_SWITCH, - SWITCH_DEPL_GPIOS, - WAIT_ON_DEPLOYMENT_FINISH, - WAIT_FOR_MAIN_SWITCH_OFF - }; + /** + * This countdown is used to wait for the burn wire being successful cut. + */ + Countdown deploymentCountdown; - StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND; + /** + * The message queue id of the component commanding an action will be stored in this variable. + * This is necessary to send later the action finish replies. + */ + MessageQueueId_t rememberCommanderId = 0; - /** - * This countdown is used to check if the PCDU sets the 8V line on in the intended time. - */ - Countdown mainSwitchCountdown; + /** Size of command queue */ + size_t cmdQueueSize = 20; - /** - * This countdown is used to wait for the burn wire being successful cut. - */ - Countdown deploymentCountdown; + /** The object ID of the GPIO driver which switches the deployment transistors */ + object_id_t gpioDriverId; + CookieIF* gpioCookie; - /** - * The message queue id of the component commanding an action will be stored in this variable. - * This is necessary to send later the action finish replies. - */ - MessageQueueId_t rememberCommanderId = 0; + /** Object id of the object responsible to switch the 8V power input. Typically the PCDU. */ + object_id_t mainLineSwitcherObjectId; - /** Size of command queue */ - size_t cmdQueueSize = 20; + /** Switch number of the 8V power switch */ + uint8_t mainLineSwitch; - /** The object ID of the GPIO driver which switches the deployment transistors */ - object_id_t gpioDriverId; + gpioId_t deplSA1; + gpioId_t deplSA2; - CookieIF * gpioCookie; + GpioIF* gpioInterface = nullptr; - /** Object id of the object responsible to switch the 8V power input. Typically the PCDU. */ - object_id_t mainLineSwitcherObjectId; + /** Time duration switches are active to cut the burn wire */ + uint32_t burnTimeMs; - /** Switch number of the 8V power switch */ - uint8_t mainLineSwitch; + /** Queue to receive messages from other objects. */ + MessageQueueIF* commandQueue = nullptr; - gpioId_t deplSA1; - gpioId_t deplSA2; + /** + * After initialization this pointer will hold the reference to the main line switcher object. + */ + PowerSwitchIF* mainLineSwitcher = nullptr; - GpioIF* gpioInterface = nullptr; + ActionHelper actionHelper; - /** Time duration switches are active to cut the burn wire */ - uint32_t burnTimeMs; + void readCommandQueue(); - /** Queue to receive messages from other objects. */ - MessageQueueIF* commandQueue = nullptr; + /** + * @brief This function performs actions dependent on the current state. + */ + void handleStateMachine(); - /** - * After initialization this pointer will hold the reference to the main line switcher object. - */ - PowerSwitchIF *mainLineSwitcher = nullptr; + /** + * @brief This function polls the 8V switch state and changes the state machine when the + * switch has been enabled. + */ + void performWaitOn8VActions(); - ActionHelper actionHelper; + /** + * @brief This functions handles the switching of the solar array deployment transistors. + */ + void switchDeploymentTransistors(); - void readCommandQueue(); - - /** - * @brief This function performs actions dependent on the current state. - */ - void handleStateMachine(); - - /** - * @brief This function polls the 8V switch state and changes the state machine when the - * switch has been enabled. - */ - void performWaitOn8VActions(); - - /** - * @brief This functions handles the switching of the solar array deployment transistors. - */ - void switchDeploymentTransistors(); - - /** - * @brief This function performs actions to finish the deployment. Essentially switches - * are turned of after the burn time has expired. - */ - void handleDeploymentFinish(); + /** + * @brief This function performs actions to finish the deployment. Essentially switches + * are turned of after the burn time has expired. + */ + void handleDeploymentFinish(); }; #endif /* MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ */ diff --git a/linux/devices/SusHandler.cpp b/linux/devices/SusHandler.cpp index 67263756..44755f41 100644 --- a/linux/devices/SusHandler.cpp +++ b/linux/devices/SusHandler.cpp @@ -1,230 +1,214 @@ #include "SusHandler.h" -#include "OBSWConfig.h" #include #include -SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId) : - DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), chipSelectId( - chipSelectId), dataset(this) { - if (comCookie == NULL) { - sif::error << "SusHandler: Invalid com cookie" << std::endl; - } - if (gpioComIF == NULL) { - sif::error << "SusHandler: Invalid GpioComIF" << std::endl; - } +#include "OBSWConfig.h" + +SusHandler::SusHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + LinuxLibgpioIF *gpioComIF, gpioId_t chipSelectId) + : DeviceHandlerBase(objectId, comIF, comCookie), + gpioComIF(gpioComIF), + chipSelectId(chipSelectId), + dataset(this) { + if (comCookie == NULL) { + sif::error << "SusHandler: Invalid com cookie" << std::endl; + } + if (gpioComIF == NULL) { + sif::error << "SusHandler: Invalid GpioComIF" << std::endl; + } } -SusHandler::~SusHandler() { -} +SusHandler::~SusHandler() {} ReturnValue_t SusHandler::performOperation(uint8_t counter) { - - if (counter != FIRST_WRITE) { - DeviceHandlerBase::performOperation(counter); - return RETURN_OK; - } - - if (mode != MODE_NORMAL) { - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - return RETURN_OK; - } - - /* If device is in normale mode the communication sequence is initiated here */ - if (communicationStep == CommunicationStep::IDLE) { - communicationStep = CommunicationStep::WRITE_SETUP; - } - - DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); - + if (counter != FIRST_WRITE) { + DeviceHandlerBase::performOperation(counter); return RETURN_OK; + } + + if (mode != MODE_NORMAL) { + DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); + return RETURN_OK; + } + + /* If device is in normale mode the communication sequence is initiated here */ + if (communicationStep == CommunicationStep::IDLE) { + communicationStep = CommunicationStep::WRITE_SETUP; + } + + DeviceHandlerBase::performOperation(DeviceHandlerIF::SEND_WRITE); + + return RETURN_OK; } ReturnValue_t SusHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } - auto spiComIF = dynamic_cast(communicationInterface); - if (spiComIF == nullptr) { - sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - spiMutex = spiComIF->getMutex(); - if (spiMutex == nullptr) { - sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - return RETURN_OK; + ReturnValue_t result = RETURN_OK; + result = DeviceHandlerBase::initialize(); + if (result != RETURN_OK) { + return result; + } + auto spiComIF = dynamic_cast(communicationInterface); + if (spiComIF == nullptr) { + sif::debug << "SusHandler::initialize: Invalid communication interface" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + spiMutex = spiComIF->getMutex(); + if (spiMutex == nullptr) { + sif::debug << "SusHandler::initialize: Failed to get spi mutex" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + return RETURN_OK; } -void SusHandler::doStartUp(){ +void SusHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void SusHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +void SusHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t SusHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (communicationStep == CommunicationStep::IDLE) { + return NOTHING_TO_SEND; + } + + if (communicationStep == CommunicationStep::WRITE_SETUP) { + *id = SUS::WRITE_SETUP; + communicationStep = CommunicationStep::START_CONVERSIONS; + } else if (communicationStep == CommunicationStep::START_CONVERSIONS) { + *id = SUS::START_CONVERSIONS; + communicationStep = CommunicationStep::READ_CONVERSIONS; + } else if (communicationStep == CommunicationStep::READ_CONVERSIONS) { + *id = SUS::READ_CONVERSIONS; + communicationStep = CommunicationStep::IDLE; + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t SusHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - if (communicationStep == CommunicationStep::IDLE) { - return NOTHING_TO_SEND; - } - - if (communicationStep == CommunicationStep::WRITE_SETUP) { - *id = SUS::WRITE_SETUP; - communicationStep = CommunicationStep::START_CONVERSIONS; - } - else if (communicationStep == CommunicationStep::START_CONVERSIONS) { - *id = SUS::START_CONVERSIONS; - communicationStep = CommunicationStep::READ_CONVERSIONS; - } - else if (communicationStep == CommunicationStep::READ_CONVERSIONS) { - *id = SUS::READ_CONVERSIONS; - communicationStep = CommunicationStep::IDLE; - } - return buildCommandFromCommand(*id, nullptr, 0); +ReturnValue_t SusHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SusHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} +ReturnValue_t SusHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (SUS::WRITE_SETUP): { + /** + * The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a + * measurement the setup has to be rewritten. There must also be a little delay between + * the transmission of the setup byte and the first conversion. Thus the conversion + * will be performed in an extra step. + * Because the chip select is driven manually by the SusHandler the SPI bus must be + * protected with a mutex here. + */ + ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs); + if (result == MutexIF::MUTEX_TIMEOUT) { + sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl; + return ERROR_LOCK_MUTEX; + } else if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" << std::endl; + return ERROR_LOCK_MUTEX; + } -ReturnValue_t SusHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(SUS::WRITE_SETUP): { - /** - * The sun sensor ADC is shutdown when CS is pulled high, so each time requesting a - * measurement the setup has to be rewritten. There must also be a little delay between - * the transmission of the setup byte and the first conversion. Thus the conversion - * will be performed in an extra step. - * Because the chip select is driven manually by the SusHandler the SPI bus must be - * protected with a mutex here. - */ - ReturnValue_t result = spiMutex->lockMutex(timeoutType, timeoutMs); - if(result == MutexIF::MUTEX_TIMEOUT) { - sif::error << "SusHandler::buildCommandFromCommand: Mutex timeout" << std::endl; - return ERROR_LOCK_MUTEX; - } - else if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "SusHandler::buildCommandFromCommand: Failed to lock spi mutex" - << std::endl; - return ERROR_LOCK_MUTEX; - } - - gpioComIF->pullLow(chipSelectId); - cmdBuffer[0] = SUS::SETUP; - rawPacket = cmdBuffer; - rawPacketLen = 1; - return RETURN_OK; - } - case(SUS::START_CONVERSIONS): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - cmdBuffer[0] = SUS::CONVERSION; - rawPacket = cmdBuffer; - rawPacketLen = 2; - return RETURN_OK; - } - case(SUS::READ_CONVERSIONS): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - rawPacket = cmdBuffer; - rawPacketLen = SUS::SIZE_READ_CONVERSIONS; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + gpioComIF->pullLow(chipSelectId); + cmdBuffer[0] = SUS::SETUP; + rawPacket = cmdBuffer; + rawPacketLen = 1; + return RETURN_OK; + } + case (SUS::START_CONVERSIONS): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + cmdBuffer[0] = SUS::CONVERSION; + rawPacket = cmdBuffer; + rawPacketLen = 2; + return RETURN_OK; + } + case (SUS::READ_CONVERSIONS): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + rawPacket = cmdBuffer; + rawPacketLen = SUS::SIZE_READ_CONVERSIONS; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void SusHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(SUS::WRITE_SETUP); - this->insertInCommandMap(SUS::START_CONVERSIONS); - this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS); + this->insertInCommandMap(SUS::WRITE_SETUP); + this->insertInCommandMap(SUS::START_CONVERSIONS); + this->insertInCommandAndReplyMap(SUS::READ_CONVERSIONS, 1, &dataset, SUS::SIZE_READ_CONVERSIONS); } -ReturnValue_t SusHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - *foundId = this->getPendingCommand(); - *foundLen = remainingSize; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t SusHandler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + *foundId = this->getPendingCommand(); + *foundLen = remainingSize; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { - case SUS::READ_CONVERSIONS: { - PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; - dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3)); - dataset.ain1 = (*(packet + 4) << 8 | *(packet + 5)); - dataset.ain2 = (*(packet + 6) << 8 | *(packet + 7)); - dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); - dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); - dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); +ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch (id) { + case SUS::READ_CONVERSIONS: { + PoolReadGuard readSet(&dataset); + dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; + dataset.ain0 = (*(packet + 2) << 8 | *(packet + 3)); + dataset.ain1 = (*(packet + 4) << 8 | *(packet + 5)); + dataset.ain2 = (*(packet + 6) << 8 | *(packet + 7)); + dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); + dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); + dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", Temperature: " - << dataset.temperatureCelcius << " °C" << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " - << std::dec << dataset.ain0 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " - << std::dec << dataset.ain1 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " - << std::dec << dataset.ain2 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " - << std::dec << dataset.ain3 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " - << std::dec << dataset.ain4 << std::endl; - sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " - << std::dec << dataset.ain5 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() + << ", Temperature: " << dataset.temperatureCelcius << " °C" << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " << std::dec + << dataset.ain0 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN1: " << std::dec + << dataset.ain1 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN2: " << std::dec + << dataset.ain2 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN3: " << std::dec + << dataset.ain3 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN4: " << std::dec + << dataset.ain4 << std::endl; + sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN5: " << std::dec + << dataset.ain5 << std::endl; #endif - /** SUS can now be shutdown and thus the SPI bus released again */ - gpioComIF->pullHigh(chipSelectId); - ReturnValue_t result = spiMutex->unlockMutex(); - if (result != RETURN_OK) { - sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" - << std::endl; - return ERROR_UNLOCK_MUTEX; - } - break; - } - default: { - sif::debug << "SusHandler::interpretDeviceReply: Unknown reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - - } - return HasReturnvaluesIF::RETURN_OK; + /** SUS can now be shutdown and thus the SPI bus released again */ + gpioComIF->pullHigh(chipSelectId); + ReturnValue_t result = spiMutex->unlockMutex(); + if (result != RETURN_OK) { + sif::error << "SusHandler::interpretDeviceReply: Failed to unlock spi mutex" << std::endl; + return ERROR_UNLOCK_MUTEX; + } + break; + } + default: { + sif::debug << "SusHandler::interpretDeviceReply: Unknown reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + return HasReturnvaluesIF::RETURN_OK; } -void SusHandler::setNormalDatapoolEntriesInvalid(){ +void SusHandler::setNormalDatapoolEntriesInvalid() {} +uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; } + +ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(SUS::TEMPERATURE_C, new PoolEntry({0.0})); + localDataPoolMap.emplace(SUS::AIN0, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN1, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN2, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN3, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN4, new PoolEntry({0})); + localDataPoolMap.emplace(SUS::AIN5, new PoolEntry({0})); + return HasReturnvaluesIF::RETURN_OK; } - -uint32_t SusHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 1000; -} - -ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(SUS::TEMPERATURE_C, new PoolEntry( { 0.0 })); - localDataPoolMap.emplace(SUS::AIN0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SUS::AIN5, new PoolEntry( { 0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/linux/devices/SusHandler.h b/linux/devices/SusHandler.h index ca9a5c45..0eab5fd0 100644 --- a/linux/devices/SusHandler.h +++ b/linux/devices/SusHandler.h @@ -1,10 +1,11 @@ #ifndef MISSION_DEVICES_SUSHANDLER_H_ #define MISSION_DEVICES_SUSHANDLER_H_ -#include "devicedefinitions/SusDefinitions.h" #include #include +#include "devicedefinitions/SusDefinitions.h" + /** * @brief This is the device handler class for the SUS sensor. The sensor is * based on the MAX1227 ADC. Details about the SUS electronic can be found at @@ -18,63 +19,55 @@ * * @author J. Meier */ -class SusHandler: public DeviceHandlerBase { -public: +class SusHandler : public DeviceHandlerBase { + public: + static const uint8_t FIRST_WRITE = 7; - static const uint8_t FIRST_WRITE = 7; + SusHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId); + virtual ~SusHandler(); - SusHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t chipSelectId); - virtual ~SusHandler(); + virtual ReturnValue_t performOperation(uint8_t counter) override; - virtual ReturnValue_t performOperation(uint8_t counter) override; + virtual ReturnValue_t initialize() override; - virtual ReturnValue_t initialize() override; + protected: + void doStartUp() override; + void doShutDown() override; + 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; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: - void doStartUp() override; - void doShutDown() override; - 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; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; -private: + static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1); - static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; + enum class CommunicationStep { IDLE, WRITE_SETUP, START_CONVERSIONS, READ_CONVERSIONS }; - static const ReturnValue_t ERROR_UNLOCK_MUTEX = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t ERROR_LOCK_MUTEX = MAKE_RETURN_CODE(0xA1); + LinuxLibgpioIF* gpioComIF = nullptr; - enum class CommunicationStep { - IDLE, - WRITE_SETUP, - START_CONVERSIONS, - READ_CONVERSIONS - }; + gpioId_t chipSelectId = gpio::NO_GPIO; - LinuxLibgpioIF* gpioComIF = nullptr; + SUS::SusDataset dataset; - gpioId_t chipSelectId = gpio::NO_GPIO; + uint8_t cmdBuffer[SUS::MAX_CMD_SIZE]; + CommunicationStep communicationStep = CommunicationStep::IDLE; - SUS::SusDataset dataset; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 20; - uint8_t cmdBuffer[SUS::MAX_CMD_SIZE]; - CommunicationStep communicationStep = CommunicationStep::IDLE; - - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 20; - - MutexIF* spiMutex = nullptr; + MutexIF* spiMutex = nullptr; }; #endif /* MISSION_DEVICES_SUSHANDLER_H_ */ diff --git a/linux/devices/devicedefinitions/SusDefinitions.h b/linux/devices/devicedefinitions/SusDefinitions.h index ba56ec07..2a45ebc5 100644 --- a/linux/devices/devicedefinitions/SusDefinitions.h +++ b/linux/devices/devicedefinitions/SusDefinitions.h @@ -3,93 +3,87 @@ #include #include -#include +#include namespace SUS { - /** - * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by - * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. - */ - static const uint32_t MAX1227_SPI_FREQ = 1000000; +/** + * Some MAX1227 could not be reached with frequencies around 4 MHz. Maybe this is caused by + * the decoder and buffer circuits. Thus frequency is here defined to 1 MHz. + */ +static const uint32_t MAX1227_SPI_FREQ = 1000000; - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - static const DeviceCommandId_t WRITE_SETUP = 0x1; - /** - * This command initiates the ADC conversion for all channels including the internal - * temperature sensor. - */ - static const DeviceCommandId_t START_CONVERSIONS = 0x2; - /** - * This command reads the internal fifo which holds the temperature and the channel - * conversions. - */ - static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +static const DeviceCommandId_t WRITE_SETUP = 0x1; +/** + * This command initiates the ADC conversion for all channels including the internal + * temperature sensor. + */ +static const DeviceCommandId_t START_CONVERSIONS = 0x2; +/** + * This command reads the internal fifo which holds the temperature and the channel + * conversions. + */ +static const DeviceCommandId_t READ_CONVERSIONS = 0x3; - /** - * @brief This is the configuration byte which will be written to the setup register after - * power on. - * - * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte - * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, Internal reference, no wake-up delay - * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, Internally clocked - * Bit7 - Bit6: 0b01, Tells MAX1227 that this byte should be - * written to the setup register - * - */ - static const uint8_t SETUP = 0b01101000; +/** + * @brief This is the configuration byte which will be written to the setup register after + * power on. + * + * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, No byte is following the setup byte + * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, Internal reference, no wake-up delay + * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, Internally clocked + * Bit7 - Bit6: 0b01, Tells MAX1227 that this byte should be + * written to the setup register + * + */ +static const uint8_t SETUP = 0b01101000; - /** - * @brief This values will always be written to the ADC conversion register to specify the - * conversions to perform. - * @details Bit0: 1 - Enables temperature conversion - * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N - * Bit6 - Bit3 defines N: 0b0101 (N = 5) - * Bit7: Always 1. Tells the ADC that this is the conversion register. - */ - static const uint8_t CONVERSION = 0b10101001; +/** + * @brief This values will always be written to the ADC conversion register to specify the + * conversions to perform. + * @details Bit0: 1 - Enables temperature conversion + * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00, Scans channels 0 through N + * Bit6 - Bit3 defines N: 0b0101 (N = 5) + * Bit7: Always 1. Tells the ADC that this is the conversion register. + */ +static const uint8_t CONVERSION = 0b10101001; - static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS; +static const uint8_t SUS_DATA_SET_ID = READ_CONVERSIONS; - /** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */ - static const uint8_t SIZE_READ_CONVERSIONS = 14; +/** Size of data replies. Temperature and 6 channel convesions (AIN0 - AIN5) */ +static const uint8_t SIZE_READ_CONVERSIONS = 14; - static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS; +static const uint8_t MAX_CMD_SIZE = SIZE_READ_CONVERSIONS; - static const uint8_t POOL_ENTRIES = 7; +static const uint8_t POOL_ENTRIES = 7; - enum Max1227PoolIds: lp_id_t { - TEMPERATURE_C, - AIN0, - AIN1, - AIN2, - AIN3, - AIN4, - AIN5, - }; - -class SusDataset: public StaticLocalDataSet { -public: - - SusDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, SUS_DATA_SET_ID) { - } - - SusDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, SUS_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); - lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); - lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); - lp_var_t ain2 = lp_var_t(sid.objectId, AIN2, this); - lp_var_t ain3 = lp_var_t(sid.objectId, AIN3, this); - lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); - lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); +enum Max1227PoolIds : lp_id_t { + TEMPERATURE_C, + AIN0, + AIN1, + AIN2, + AIN3, + AIN4, + AIN5, }; -} +class SusDataset : public StaticLocalDataSet { + public: + SusDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, SUS_DATA_SET_ID) {} + + SusDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, SUS_DATA_SET_ID)) {} + + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); + lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); + lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); + lp_var_t ain2 = lp_var_t(sid.objectId, AIN2, this); + lp_var_t ain3 = lp_var_t(sid.objectId, AIN3, this); + lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); + lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); +}; +} // namespace SUS #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SUS_H_ */ diff --git a/linux/fsfwconfig/devices/addresses.cpp b/linux/fsfwconfig/devices/addresses.cpp index 38877737..60b1370b 100644 --- a/linux/fsfwconfig/devices/addresses.cpp +++ b/linux/fsfwconfig/devices/addresses.cpp @@ -5,7 +5,3 @@ */ #include "addresses.h" - - - - diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index 94f22c54..5ef82788 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -2,84 +2,85 @@ #define FSFWCONFIG_DEVICES_ADDRESSES_H_ #include -#include "objects/systemObjectList.h" + #include +#include "objects/systemObjectList.h" + namespace addresses { - /* Logical addresses have uint32_t datatype */ - enum logicalAddresses: address_t { - PCDU, +/* Logical addresses have uint32_t datatype */ +enum logicalAddresses : address_t { + PCDU, - MGM_0_LIS3 = objects::MGM_0_LIS3_HANDLER, - MGM_1_RM3100 = objects::MGM_1_RM3100_HANDLER, - MGM_2_LIS3 = objects::MGM_2_LIS3_HANDLER, - MGM_3_RM3100 = objects::MGM_3_RM3100_HANDLER, + MGM_0_LIS3 = objects::MGM_0_LIS3_HANDLER, + MGM_1_RM3100 = objects::MGM_1_RM3100_HANDLER, + MGM_2_LIS3 = objects::MGM_2_LIS3_HANDLER, + MGM_3_RM3100 = objects::MGM_3_RM3100_HANDLER, - GYRO_0_ADIS = objects::GYRO_0_ADIS_HANDLER, - GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER, - GYRO_2_ADIS = objects::GYRO_2_ADIS_HANDLER, - GYRO_3_L3G = objects::GYRO_3_L3G_HANDLER, + GYRO_0_ADIS = objects::GYRO_0_ADIS_HANDLER, + GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER, + GYRO_2_ADIS = objects::GYRO_2_ADIS_HANDLER, + GYRO_3_L3G = objects::GYRO_3_L3G_HANDLER, - RAD_SENSOR = objects::RAD_SENSOR, + RAD_SENSOR = objects::RAD_SENSOR, - SUS_1 = objects::SUS_1, - SUS_2 = objects::SUS_2, - SUS_3 = objects::SUS_3, - SUS_4 = objects::SUS_4, - SUS_5 = objects::SUS_5, - SUS_6 = objects::SUS_6, - SUS_7 = objects::SUS_7, - SUS_8 = objects::SUS_8, - SUS_9 = objects::SUS_9, - SUS_10 = objects::SUS_10, - SUS_11 = objects::SUS_11, - SUS_12 = objects::SUS_12, - SUS_13 = objects::SUS_13, + SUS_1 = objects::SUS_1, + SUS_2 = objects::SUS_2, + SUS_3 = objects::SUS_3, + SUS_4 = objects::SUS_4, + SUS_5 = objects::SUS_5, + SUS_6 = objects::SUS_6, + SUS_7 = objects::SUS_7, + SUS_8 = objects::SUS_8, + SUS_9 = objects::SUS_9, + SUS_10 = objects::SUS_10, + SUS_11 = objects::SUS_11, + SUS_12 = objects::SUS_12, + SUS_13 = objects::SUS_13, - /* Dummy and Test Addresses */ - DUMMY_ECHO = 129, - DUMMY_GPS0 = 130, - DUMMY_GPS1 = 131, - }; + /* Dummy and Test Addresses */ + DUMMY_ECHO = 129, + DUMMY_GPS0 = 130, + DUMMY_GPS1 = 131, +}; - enum i2cAddresses: address_t { - IMTQ = 16, - TMP1075_TCS_1 = 72, - TMP1075_TCS_2 = 73, - }; +enum i2cAddresses : address_t { + IMTQ = 16, + TMP1075_TCS_1 = 72, + TMP1075_TCS_2 = 73, +}; - enum spiAddresses: address_t { - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, - RW1, - RW2, - RW3, - RW4 - }; - - /* Addresses of devices supporting the CSP protocol */ - enum cspAddresses: uint8_t { - P60DOCK = 4, - ACU = 2, - PDU1 = 3, - /* PDU2 occupies X4 slot of P60Dock */ - PDU2 = 6 - }; -} +enum spiAddresses : address_t { + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, + RW1, + RW2, + RW3, + RW4 +}; +/* Addresses of devices supporting the CSP protocol */ +enum cspAddresses : uint8_t { + P60DOCK = 4, + ACU = 2, + PDU1 = 3, + /* PDU2 occupies X4 slot of P60Dock */ + PDU2 = 6 +}; +} // namespace addresses #endif /* FSFWCONFIG_DEVICES_ADDRESSES_H_ */ diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index e4b9f727..bb753a30 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -5,116 +5,112 @@ namespace gpioIds { enum gpioId_t { - HEATER_0, - HEATER_1, - HEATER_2, - HEATER_3, - HEATER_4, - HEATER_5, - HEATER_6, - HEATER_7, - DEPLSA1, - DEPLSA2, + HEATER_0, + HEATER_1, + HEATER_2, + HEATER_3, + HEATER_4, + HEATER_5, + HEATER_6, + HEATER_7, + DEPLSA1, + DEPLSA2, - MGM_0_LIS3_CS, - MGM_1_RM3100_CS, - GYRO_0_ADIS_CS, - GYRO_1_L3G_CS, - GYRO_2_ADIS_CS, - GYRO_3_L3G_CS, - MGM_2_LIS3_CS, - MGM_3_RM3100_CS, + MGM_0_LIS3_CS, + MGM_1_RM3100_CS, + GYRO_0_ADIS_CS, + GYRO_1_L3G_CS, + GYRO_2_ADIS_CS, + GYRO_3_L3G_CS, + MGM_2_LIS3_CS, + MGM_3_RM3100_CS, - GNSS_0_NRESET, - GNSS_1_NRESET, - GNSS_0_ENABLE, - GNSS_1_ENABLE, + GNSS_0_NRESET, + GNSS_1_NRESET, + GNSS_0_ENABLE, + GNSS_1_ENABLE, - GYRO_0_ENABLE, - GYRO_2_ENABLE, + GYRO_0_ENABLE, + GYRO_2_ENABLE, - TEST_ID_0, - TEST_ID_1, + TEST_ID_0, + TEST_ID_1, - RTD_IC_3, - RTD_IC_4, - RTD_IC_5, - RTD_IC_6, - RTD_IC_7, - RTD_IC_8, - RTD_IC_9, - RTD_IC_10, - RTD_IC_11, - RTD_IC_12, - RTD_IC_13, - RTD_IC_14, - RTD_IC_15, - RTD_IC_16, - RTD_IC_17, - RTD_IC_18, + RTD_IC_3, + RTD_IC_4, + RTD_IC_5, + RTD_IC_6, + RTD_IC_7, + RTD_IC_8, + RTD_IC_9, + RTD_IC_10, + RTD_IC_11, + RTD_IC_12, + RTD_IC_13, + RTD_IC_14, + RTD_IC_15, + RTD_IC_16, + RTD_IC_17, + RTD_IC_18, - CS_SUS_1, - CS_SUS_2, - CS_SUS_3, - CS_SUS_4, - CS_SUS_5, - CS_SUS_6, - CS_SUS_7, - CS_SUS_8, - CS_SUS_9, - CS_SUS_10, - CS_SUS_11, - CS_SUS_12, - CS_SUS_13, + CS_SUS_1, + CS_SUS_2, + CS_SUS_3, + CS_SUS_4, + CS_SUS_5, + CS_SUS_6, + CS_SUS_7, + CS_SUS_8, + CS_SUS_9, + CS_SUS_10, + CS_SUS_11, + CS_SUS_12, + CS_SUS_13, - SPI_MUX_BIT_1, - SPI_MUX_BIT_2, - SPI_MUX_BIT_3, - SPI_MUX_BIT_4, - SPI_MUX_BIT_5, - SPI_MUX_BIT_6, + SPI_MUX_BIT_1, + SPI_MUX_BIT_2, + SPI_MUX_BIT_3, + SPI_MUX_BIT_4, + SPI_MUX_BIT_5, + SPI_MUX_BIT_6, - CS_RAD_SENSOR, + CS_RAD_SENSOR, - PAPB_BUSY_N, - PAPB_EMPTY, + PAPB_BUSY_N, + PAPB_EMPTY, - EN_RW1, - EN_RW2, - EN_RW3, - EN_RW4, + EN_RW1, + EN_RW2, + EN_RW3, + EN_RW4, - CS_RW1, - CS_RW2, - CS_RW3, - CS_RW4, + CS_RW1, + CS_RW2, + CS_RW3, + CS_RW4, - EN_RW_CS, + EN_RW_CS, - SPI_MUX, + SPI_MUX, - VC0_PAPB_EMPTY, - VC0_PAPB_BUSY, - VC1_PAPB_EMPTY, - VC1_PAPB_BUSY, - VC2_PAPB_EMPTY, - VC2_PAPB_BUSY, - VC3_PAPB_EMPTY, - VC3_PAPB_BUSY, + VC0_PAPB_EMPTY, + VC0_PAPB_BUSY, + VC1_PAPB_EMPTY, + VC1_PAPB_BUSY, + VC2_PAPB_EMPTY, + VC2_PAPB_BUSY, + VC3_PAPB_EMPTY, + VC3_PAPB_BUSY, - PDEC_RESET, + PDEC_RESET, + RS485_EN_TX_DATA, + RS485_EN_TX_CLOCK, + RS485_EN_RX_DATA, + RS485_EN_RX_CLOCK, - RS485_EN_TX_DATA, - RS485_EN_TX_CLOCK, - RS485_EN_RX_DATA, - RS485_EN_RX_CLOCK, - - BIT_RATE_SEL + BIT_RATE_SEL }; } - - - #endif /* FSFWCONFIG_DEVICES_GPIOIDS_H_ */ diff --git a/linux/fsfwconfig/devices/powerSwitcherList.h b/linux/fsfwconfig/devices/powerSwitcherList.h index bc5731fd..cc6bc141 100644 --- a/linux/fsfwconfig/devices/powerSwitcherList.h +++ b/linux/fsfwconfig/devices/powerSwitcherList.h @@ -4,55 +4,54 @@ #include "OBSWConfig.h" namespace pcduSwitches { - /* Switches are uint8_t datatype and go from 0 to 255 */ - enum SwitcherList: uint8_t { - Q7S, - PAYLOAD_PCDU_CH1, - RW, - TCS_BOARD_8V_HEATER_IN, - SUS_REDUNDANT, - DEPLOYMENT_MECHANISM, - PAYLOAD_PCDU_CH6, - ACS_BOARD_SIDE_B, - PAYLOAD_CAMERA, - TCS_BOARD_3V3, - SYRLINKS, - STAR_TRACKER, - MGT, - SUS_NOMINAL, - SOLAR_CELL_EXP, - PLOC, - ACS_BOARD_SIDE_A, - NUMBER_OF_SWITCHES - }; +/* Switches are uint8_t datatype and go from 0 to 255 */ +enum SwitcherList : uint8_t { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES +}; - static const uint8_t ON = 1; - static const uint8_t OFF = 0; +static const uint8_t ON = 1; +static const uint8_t OFF = 0; - /* Output states after reboot of the PDUs */ - static const uint8_t INIT_STATE_Q7S = ON; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; - static const uint8_t INIT_STATE_RW = OFF; +/* Output states after reboot of the PDUs */ +static const uint8_t INIT_STATE_Q7S = ON; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; +static const uint8_t INIT_STATE_RW = OFF; #if BOARD_TE0720 == 1 - /* Because the TE0720 is not connected to the PCDU, this switch is always on */ - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +/* Because the TE0720 is not connected to the PCDU, this switch is always on */ +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; #else - static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; #endif - static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; - static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; - static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; - static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; - static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; - static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; - static const uint8_t INIT_STATE_SYRLINKS = OFF; - static const uint8_t INIT_STATE_STAR_TRACKER = OFF; - static const uint8_t INIT_STATE_MGT = OFF; - static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; - 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; -} - +static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; +static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; +static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; +static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; +static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; +static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; +static const uint8_t INIT_STATE_SYRLINKS = OFF; +static const uint8_t INIT_STATE_STAR_TRACKER = OFF; +static const uint8_t INIT_STATE_MGT = OFF; +static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; +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_ */ diff --git a/linux/fsfwconfig/events/subsystemIdRanges.h b/linux/fsfwconfig/events/subsystemIdRanges.h index 4894be16..33ef1a09 100644 --- a/linux/fsfwconfig/events/subsystemIdRanges.h +++ b/linux/fsfwconfig/events/subsystemIdRanges.h @@ -1,19 +1,19 @@ #ifndef FSFWCONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #define FSFWCONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ +#include + #include "common/config/commonSubsystemIds.h" #include "fsfw/events/fwSubsystemIdRanges.h" -#include - /** * These IDs are part of the ID for an event thrown by a subsystem. * Numbers 0-80 are reserved for FSFW Subsystem IDs (framework/events/) */ namespace SUBSYSTEM_ID { -enum: uint8_t { - SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END, - CORE = 116, +enum : uint8_t { + SUBSYSTEM_ID_START = COMMON_SUBSYSTEM_ID_END, + CORE = 116, }; } diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 11a02c64..9ee9f3cf 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -146,290 +146,290 @@ const char *STR_HELPER_FILE_NOT_EXISTS_STRING = "STR_HELPER_FILE_NOT_EXISTS"; const char *STR_HELPER_SENDING_PACKET_FAILED_STRING = "STR_HELPER_SENDING_PACKET_FAILED"; const char *STR_HELPER_REQUESTING_MSG_FAILED_STRING = "STR_HELPER_REQUESTING_MSG_FAILED"; -const char * translateEvents(Event event) { - switch( (event & 0xffff) ) { - case(2200): - return STORE_SEND_WRITE_FAILED_STRING; - case(2201): - return STORE_WRITE_FAILED_STRING; - case(2202): - return STORE_SEND_READ_FAILED_STRING; - case(2203): - return STORE_READ_FAILED_STRING; - case(2204): - return UNEXPECTED_MSG_STRING; - case(2205): - return STORING_FAILED_STRING; - case(2206): - return TM_DUMP_FAILED_STRING; - case(2207): - return STORE_INIT_FAILED_STRING; - case(2208): - return STORE_INIT_EMPTY_STRING; - case(2209): - return STORE_CONTENT_CORRUPTED_STRING; - case(2210): - return STORE_INITIALIZE_STRING; - case(2211): - return INIT_DONE_STRING; - case(2212): - return DUMP_FINISHED_STRING; - case(2213): - return DELETION_FINISHED_STRING; - case(2214): - return DELETION_FAILED_STRING; - case(2215): - return AUTO_CATALOGS_SENDING_FAILED_STRING; - case(2600): - return GET_DATA_FAILED_STRING; - case(2601): - return STORE_DATA_FAILED_STRING; - case(2800): - return DEVICE_BUILDING_COMMAND_FAILED_STRING; - case(2801): - return DEVICE_SENDING_COMMAND_FAILED_STRING; - case(2802): - return DEVICE_REQUESTING_REPLY_FAILED_STRING; - case(2803): - return DEVICE_READING_REPLY_FAILED_STRING; - case(2804): - return DEVICE_INTERPRETING_REPLY_FAILED_STRING; - case(2805): - return DEVICE_MISSED_REPLY_STRING; - case(2806): - return DEVICE_UNKNOWN_REPLY_STRING; - case(2807): - return DEVICE_UNREQUESTED_REPLY_STRING; - case(2808): - return INVALID_DEVICE_COMMAND_STRING; - case(2809): - return MONITORING_LIMIT_EXCEEDED_STRING; - case(2810): - return MONITORING_AMBIGUOUS_STRING; - case(4201): - return FUSE_CURRENT_HIGH_STRING; - case(4202): - return FUSE_WENT_OFF_STRING; - case(4204): - return POWER_ABOVE_HIGH_LIMIT_STRING; - case(4205): - return POWER_BELOW_LOW_LIMIT_STRING; - case(4300): - return SWITCH_WENT_OFF_STRING; - case(5000): - return HEATER_ON_STRING; - case(5001): - return HEATER_OFF_STRING; - case(5002): - return HEATER_TIMEOUT_STRING; - case(5003): - return HEATER_STAYED_ON_STRING; - case(5004): - return HEATER_STAYED_OFF_STRING; - case(5200): - return TEMP_SENSOR_HIGH_STRING; - case(5201): - return TEMP_SENSOR_LOW_STRING; - case(5202): - return TEMP_SENSOR_GRADIENT_STRING; - case(5901): - return COMPONENT_TEMP_LOW_STRING; - case(5902): - return COMPONENT_TEMP_HIGH_STRING; - case(5903): - return COMPONENT_TEMP_OOL_LOW_STRING; - case(5904): - return COMPONENT_TEMP_OOL_HIGH_STRING; - case(5905): - return TEMP_NOT_IN_OP_RANGE_STRING; - case(7101): - return FDIR_CHANGED_STATE_STRING; - case(7102): - return FDIR_STARTS_RECOVERY_STRING; - case(7103): - return FDIR_TURNS_OFF_DEVICE_STRING; - case(7201): - return MONITOR_CHANGED_STATE_STRING; - case(7202): - return VALUE_BELOW_LOW_LIMIT_STRING; - case(7203): - return VALUE_ABOVE_HIGH_LIMIT_STRING; - case(7204): - return VALUE_OUT_OF_RANGE_STRING; - case(7301): - return SWITCHING_TM_FAILED_STRING; - case(7400): - return CHANGING_MODE_STRING; - case(7401): - return MODE_INFO_STRING; - case(7402): - return FALLBACK_FAILED_STRING; - case(7403): - return MODE_TRANSITION_FAILED_STRING; - case(7404): - return CANT_KEEP_MODE_STRING; - case(7405): - return OBJECT_IN_INVALID_MODE_STRING; - case(7406): - return FORCING_MODE_STRING; - case(7407): - return MODE_CMD_REJECTED_STRING; - case(7506): - return HEALTH_INFO_STRING; - case(7507): - return CHILD_CHANGED_HEALTH_STRING; - case(7508): - return CHILD_PROBLEMS_STRING; - case(7509): - return OVERWRITING_HEALTH_STRING; - case(7510): - return TRYING_RECOVERY_STRING; - case(7511): - return RECOVERY_STEP_STRING; - case(7512): - return RECOVERY_DONE_STRING; - case(7900): - return RF_AVAILABLE_STRING; - case(7901): - return RF_LOST_STRING; - case(7902): - return BIT_LOCK_STRING; - case(7903): - return BIT_LOCK_LOST_STRING; - case(7905): - return FRAME_PROCESSING_FAILED_STRING; - case(8900): - return CLOCK_SET_STRING; - case(8901): - return CLOCK_SET_FAILURE_STRING; - case(9700): - return TEST_STRING; - case(10600): - return CHANGE_OF_SETUP_PARAMETER_STRING; - case(10900): - return GPIO_PULL_HIGH_FAILED_STRING; - case(10901): - return GPIO_PULL_LOW_FAILED_STRING; - case(10902): - return SWITCH_ALREADY_ON_STRING; - case(10903): - return SWITCH_ALREADY_OFF_STRING; - case(10904): - return MAIN_SWITCH_TIMEOUT_STRING; - case(11000): - return MAIN_SWITCH_ON_TIMEOUT_STRING; - case(11001): - return MAIN_SWITCH_OFF_TIMEOUT_STRING; - case(11002): - return DEPLOYMENT_FAILED_STRING; - case(11003): - return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; - case(11004): - return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; - case(11101): - return MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11102): - return ACK_FAILURE_STRING; - case(11103): - return EXE_FAILURE_STRING; - case(11104): - return CRC_FAILURE_EVENT_STRING; - case(11201): - return SELF_TEST_I2C_FAILURE_STRING; - case(11202): - return SELF_TEST_SPI_FAILURE_STRING; - case(11203): - return SELF_TEST_ADC_FAILURE_STRING; - case(11204): - return SELF_TEST_PWM_FAILURE_STRING; - case(11205): - return SELF_TEST_TC_FAILURE_STRING; - case(11206): - return SELF_TEST_MTM_RANGE_FAILURE_STRING; - case(11207): - return SELF_TEST_COIL_CURRENT_FAILURE_STRING; - case(11208): - return INVALID_ERROR_BYTE_STRING; - case(11301): - return ERROR_STATE_STRING; - case(11501): - return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; - case(11502): - return SUPV_ACK_FAILURE_STRING; - case(11503): - return SUPV_EXE_FAILURE_STRING; - case(11504): - return SUPV_CRC_FAILURE_EVENT_STRING; - case(11600): - return SANITIZATION_FAILED_STRING; - case(11700): - return UPDATE_FILE_NOT_EXISTS_STRING; - case(11701): - return ACTION_COMMANDING_FAILED_STRING; - case(11702): - return UPDATE_AVAILABLE_FAILED_STRING; - case(11703): - return UPDATE_TRANSFER_FAILED_STRING; - case(11704): - return UPDATE_VERIFY_FAILED_STRING; - case(11705): - return UPDATE_FINISHED_STRING; - case(11800): - return SEND_MRAM_DUMP_FAILED_STRING; - case(11801): - return MRAM_DUMP_FAILED_STRING; - case(11802): - return MRAM_DUMP_FINISHED_STRING; - case(11901): - return INVALID_TC_FRAME_STRING; - case(11902): - return INVALID_FAR_STRING; - case(11903): - return CARRIER_LOCK_STRING; - case(11904): - return BIT_LOCK_PDEC_STRING; - case(12000): - return IMAGE_UPLOAD_FAILED_STRING; - case(12001): - return IMAGE_DOWNLOAD_FAILED_STRING; - case(12002): - return IMAGE_UPLOAD_SUCCESSFUL_STRING; - case(12003): - return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; - case(12004): - return FLASH_WRITE_SUCCESSFUL_STRING; - case(12005): - return FLASH_READ_SUCCESSFUL_STRING; - case(12006): - return FLASH_WRITE_FAILED_STRING; - case(12007): - return FLASH_READ_FAILED_STRING; - case(12008): - return FPGA_DOWNLOAD_SUCCESSFUL_STRING; - case(12009): - return FPGA_DOWNLOAD_FAILED_STRING; - case(12010): - return FPGA_UPLOAD_SUCCESSFUL_STRING; - case(12011): - return FPGA_UPLOAD_FAILED_STRING; - case(12012): - return STR_HELPER_READING_REPLY_FAILED_STRING; - case(12013): - return STR_HELPER_COM_ERROR_STRING; - case(12014): - return STR_HELPER_NO_REPLY_STRING; - case(12015): - return STR_HELPER_DEC_ERROR_STRING; - case(12016): - return POSITION_MISMATCH_STRING; - case(12017): - return STR_HELPER_FILE_NOT_EXISTS_STRING; - case(12018): - return STR_HELPER_SENDING_PACKET_FAILED_STRING; - case(12019): - return STR_HELPER_REQUESTING_MSG_FAILED_STRING; - default: - return "UNKNOWN_EVENT"; - } - return 0; +const char *translateEvents(Event event) { + switch ((event & 0xffff)) { + case (2200): + return STORE_SEND_WRITE_FAILED_STRING; + case (2201): + return STORE_WRITE_FAILED_STRING; + case (2202): + return STORE_SEND_READ_FAILED_STRING; + case (2203): + return STORE_READ_FAILED_STRING; + case (2204): + return UNEXPECTED_MSG_STRING; + case (2205): + return STORING_FAILED_STRING; + case (2206): + return TM_DUMP_FAILED_STRING; + case (2207): + return STORE_INIT_FAILED_STRING; + case (2208): + return STORE_INIT_EMPTY_STRING; + case (2209): + return STORE_CONTENT_CORRUPTED_STRING; + case (2210): + return STORE_INITIALIZE_STRING; + case (2211): + return INIT_DONE_STRING; + case (2212): + return DUMP_FINISHED_STRING; + case (2213): + return DELETION_FINISHED_STRING; + case (2214): + return DELETION_FAILED_STRING; + case (2215): + return AUTO_CATALOGS_SENDING_FAILED_STRING; + case (2600): + return GET_DATA_FAILED_STRING; + case (2601): + return STORE_DATA_FAILED_STRING; + case (2800): + return DEVICE_BUILDING_COMMAND_FAILED_STRING; + case (2801): + return DEVICE_SENDING_COMMAND_FAILED_STRING; + case (2802): + return DEVICE_REQUESTING_REPLY_FAILED_STRING; + case (2803): + return DEVICE_READING_REPLY_FAILED_STRING; + case (2804): + return DEVICE_INTERPRETING_REPLY_FAILED_STRING; + case (2805): + return DEVICE_MISSED_REPLY_STRING; + case (2806): + return DEVICE_UNKNOWN_REPLY_STRING; + case (2807): + return DEVICE_UNREQUESTED_REPLY_STRING; + case (2808): + return INVALID_DEVICE_COMMAND_STRING; + case (2809): + return MONITORING_LIMIT_EXCEEDED_STRING; + case (2810): + return MONITORING_AMBIGUOUS_STRING; + case (4201): + return FUSE_CURRENT_HIGH_STRING; + case (4202): + return FUSE_WENT_OFF_STRING; + case (4204): + return POWER_ABOVE_HIGH_LIMIT_STRING; + case (4205): + return POWER_BELOW_LOW_LIMIT_STRING; + case (4300): + return SWITCH_WENT_OFF_STRING; + case (5000): + return HEATER_ON_STRING; + case (5001): + return HEATER_OFF_STRING; + case (5002): + return HEATER_TIMEOUT_STRING; + case (5003): + return HEATER_STAYED_ON_STRING; + case (5004): + return HEATER_STAYED_OFF_STRING; + case (5200): + return TEMP_SENSOR_HIGH_STRING; + case (5201): + return TEMP_SENSOR_LOW_STRING; + case (5202): + return TEMP_SENSOR_GRADIENT_STRING; + case (5901): + return COMPONENT_TEMP_LOW_STRING; + case (5902): + return COMPONENT_TEMP_HIGH_STRING; + case (5903): + return COMPONENT_TEMP_OOL_LOW_STRING; + case (5904): + return COMPONENT_TEMP_OOL_HIGH_STRING; + case (5905): + return TEMP_NOT_IN_OP_RANGE_STRING; + case (7101): + return FDIR_CHANGED_STATE_STRING; + case (7102): + return FDIR_STARTS_RECOVERY_STRING; + case (7103): + return FDIR_TURNS_OFF_DEVICE_STRING; + case (7201): + return MONITOR_CHANGED_STATE_STRING; + case (7202): + return VALUE_BELOW_LOW_LIMIT_STRING; + case (7203): + return VALUE_ABOVE_HIGH_LIMIT_STRING; + case (7204): + return VALUE_OUT_OF_RANGE_STRING; + case (7301): + return SWITCHING_TM_FAILED_STRING; + case (7400): + return CHANGING_MODE_STRING; + case (7401): + return MODE_INFO_STRING; + case (7402): + return FALLBACK_FAILED_STRING; + case (7403): + return MODE_TRANSITION_FAILED_STRING; + case (7404): + return CANT_KEEP_MODE_STRING; + case (7405): + return OBJECT_IN_INVALID_MODE_STRING; + case (7406): + return FORCING_MODE_STRING; + case (7407): + return MODE_CMD_REJECTED_STRING; + case (7506): + return HEALTH_INFO_STRING; + case (7507): + return CHILD_CHANGED_HEALTH_STRING; + case (7508): + return CHILD_PROBLEMS_STRING; + case (7509): + return OVERWRITING_HEALTH_STRING; + case (7510): + return TRYING_RECOVERY_STRING; + case (7511): + return RECOVERY_STEP_STRING; + case (7512): + return RECOVERY_DONE_STRING; + case (7900): + return RF_AVAILABLE_STRING; + case (7901): + return RF_LOST_STRING; + case (7902): + return BIT_LOCK_STRING; + case (7903): + return BIT_LOCK_LOST_STRING; + case (7905): + return FRAME_PROCESSING_FAILED_STRING; + case (8900): + return CLOCK_SET_STRING; + case (8901): + return CLOCK_SET_FAILURE_STRING; + case (9700): + return TEST_STRING; + case (10600): + return CHANGE_OF_SETUP_PARAMETER_STRING; + case (10900): + return GPIO_PULL_HIGH_FAILED_STRING; + case (10901): + return GPIO_PULL_LOW_FAILED_STRING; + case (10902): + return SWITCH_ALREADY_ON_STRING; + case (10903): + return SWITCH_ALREADY_OFF_STRING; + case (10904): + return MAIN_SWITCH_TIMEOUT_STRING; + case (11000): + return MAIN_SWITCH_ON_TIMEOUT_STRING; + case (11001): + return MAIN_SWITCH_OFF_TIMEOUT_STRING; + case (11002): + return DEPLOYMENT_FAILED_STRING; + case (11003): + return DEPL_SA1_GPIO_SWTICH_ON_FAILED_STRING; + case (11004): + return DEPL_SA2_GPIO_SWTICH_ON_FAILED_STRING; + case (11101): + return MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11102): + return ACK_FAILURE_STRING; + case (11103): + return EXE_FAILURE_STRING; + case (11104): + return CRC_FAILURE_EVENT_STRING; + case (11201): + return SELF_TEST_I2C_FAILURE_STRING; + case (11202): + return SELF_TEST_SPI_FAILURE_STRING; + case (11203): + return SELF_TEST_ADC_FAILURE_STRING; + case (11204): + return SELF_TEST_PWM_FAILURE_STRING; + case (11205): + return SELF_TEST_TC_FAILURE_STRING; + case (11206): + return SELF_TEST_MTM_RANGE_FAILURE_STRING; + case (11207): + return SELF_TEST_COIL_CURRENT_FAILURE_STRING; + case (11208): + return INVALID_ERROR_BYTE_STRING; + case (11301): + return ERROR_STATE_STRING; + case (11501): + return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; + case (11502): + return SUPV_ACK_FAILURE_STRING; + case (11503): + return SUPV_EXE_FAILURE_STRING; + case (11504): + return SUPV_CRC_FAILURE_EVENT_STRING; + case (11600): + return SANITIZATION_FAILED_STRING; + case (11700): + return UPDATE_FILE_NOT_EXISTS_STRING; + case (11701): + return ACTION_COMMANDING_FAILED_STRING; + case (11702): + return UPDATE_AVAILABLE_FAILED_STRING; + case (11703): + return UPDATE_TRANSFER_FAILED_STRING; + case (11704): + return UPDATE_VERIFY_FAILED_STRING; + case (11705): + return UPDATE_FINISHED_STRING; + case (11800): + return SEND_MRAM_DUMP_FAILED_STRING; + case (11801): + return MRAM_DUMP_FAILED_STRING; + case (11802): + return MRAM_DUMP_FINISHED_STRING; + case (11901): + return INVALID_TC_FRAME_STRING; + case (11902): + return INVALID_FAR_STRING; + case (11903): + return CARRIER_LOCK_STRING; + case (11904): + return BIT_LOCK_PDEC_STRING; + case (12000): + return IMAGE_UPLOAD_FAILED_STRING; + case (12001): + return IMAGE_DOWNLOAD_FAILED_STRING; + case (12002): + return IMAGE_UPLOAD_SUCCESSFUL_STRING; + case (12003): + return IMAGE_DOWNLOAD_SUCCESSFUL_STRING; + case (12004): + return FLASH_WRITE_SUCCESSFUL_STRING; + case (12005): + return FLASH_READ_SUCCESSFUL_STRING; + case (12006): + return FLASH_WRITE_FAILED_STRING; + case (12007): + return FLASH_READ_FAILED_STRING; + case (12008): + return FPGA_DOWNLOAD_SUCCESSFUL_STRING; + case (12009): + return FPGA_DOWNLOAD_FAILED_STRING; + case (12010): + return FPGA_UPLOAD_SUCCESSFUL_STRING; + case (12011): + return FPGA_UPLOAD_FAILED_STRING; + case (12012): + return STR_HELPER_READING_REPLY_FAILED_STRING; + case (12013): + return STR_HELPER_COM_ERROR_STRING; + case (12014): + return STR_HELPER_NO_REPLY_STRING; + case (12015): + return STR_HELPER_DEC_ERROR_STRING; + case (12016): + return POSITION_MISMATCH_STRING; + case (12017): + return STR_HELPER_FILE_NOT_EXISTS_STRING; + case (12018): + return STR_HELPER_SENDING_PACKET_FAILED_STRING; + case (12019): + return STR_HELPER_REQUESTING_MSG_FAILED_STRING; + default: + return "UNKNOWN_EVENT"; + } + return 0; } diff --git a/linux/fsfwconfig/events/translateEvents.h b/linux/fsfwconfig/events/translateEvents.h index bdabb21b..1b8a8831 100644 --- a/linux/fsfwconfig/events/translateEvents.h +++ b/linux/fsfwconfig/events/translateEvents.h @@ -3,6 +3,6 @@ #include "fsfw/events/Event.h" -const char * translateEvents(Event event); +const char* translateEvents(Event event); #endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ diff --git a/linux/fsfwconfig/ipc/MissionMessageTypes.cpp b/linux/fsfwconfig/ipc/MissionMessageTypes.cpp index 9ac6f0f4..fa1c4877 100644 --- a/linux/fsfwconfig/ipc/MissionMessageTypes.cpp +++ b/linux/fsfwconfig/ipc/MissionMessageTypes.cpp @@ -1,12 +1,10 @@ #include "MissionMessageTypes.h" + #include - void messagetypes::clearMissionMessage(CommandMessage* message) { - switch(message->getMessageType()) { - default: - break; - } + switch (message->getMessageType()) { + default: + break; + } } - - diff --git a/linux/fsfwconfig/ipc/MissionMessageTypes.h b/linux/fsfwconfig/ipc/MissionMessageTypes.h index ab2a84b5..78b0d343 100644 --- a/linux/fsfwconfig/ipc/MissionMessageTypes.h +++ b/linux/fsfwconfig/ipc/MissionMessageTypes.h @@ -11,12 +11,12 @@ class CommandMessage; * * @param message Generic Command Message */ -namespace messagetypes{ +namespace messagetypes { enum MESSAGE_TYPE { - MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, }; void clearMissionMessage(CommandMessage* message); -} +} // namespace messagetypes #endif /* FSFWCONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index a8929187..c868730b 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -1,10 +1,12 @@ #ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#include "commonObjects.h" #include + #include +#include "commonObjects.h" + // The objects will be instantiated in the ID order // For naming scheme see flight manual /* @@ -31,38 +33,38 @@ Fourth byte is a unique counter. */ namespace objects { -enum sourceObjects: uint32_t { - /* 0x53 reserved for FSFW */ - FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, - FW_ADDRESS_END = TIME_STAMPER, - PUS_SERVICE_6 = 0x51000500, +enum sourceObjects : uint32_t { + /* 0x53 reserved for FSFW */ + FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, + FW_ADDRESS_END = TIME_STAMPER, + PUS_SERVICE_6 = 0x51000500, - CCSDS_IP_CORE_BRIDGE = 0x73500000, - TM_FUNNEL = 0x73000100, + CCSDS_IP_CORE_BRIDGE = 0x73500000, + TM_FUNNEL = 0x73000100, - /* 0x49 ('I') for Communication Interfaces **/ - ARDUINO_COM_IF = 0x49000000, - CSP_COM_IF = 0x49050001, - I2C_COM_IF = 0x49040002, - UART_COM_IF = 0x49030003, - SPI_COM_IF = 0x49020004, - GPIO_IF = 0x49010005, + /* 0x49 ('I') for Communication Interfaces **/ + ARDUINO_COM_IF = 0x49000000, + CSP_COM_IF = 0x49050001, + I2C_COM_IF = 0x49040002, + UART_COM_IF = 0x49030003, + SPI_COM_IF = 0x49020004, + GPIO_IF = 0x49010005, - /* Custom device handler */ - PCDU_HANDLER = 0x442000A1, - SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, - SYRLINKS_HK_HANDLER = 0x445300A3, - HEATER_HANDLER = 0x444100A4, - RAD_SENSOR = 0x443200A5, + /* Custom device handler */ + PCDU_HANDLER = 0x442000A1, + SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, + SYRLINKS_HK_HANDLER = 0x445300A3, + HEATER_HANDLER = 0x444100A4, + RAD_SENSOR = 0x443200A5, - /* 0x54 ('T') for test handlers */ - TEST_TASK = 0x54694269, - LIBGPIOD_TEST = 0x54123456, - SPI_TEST = 0x54000010, - UART_TEST = 0x54000020, - DUMMY_INTERFACE = 0x5400CAFE, - DUMMY_HANDLER = 0x5400AFFE, - P60DOCK_TEST_TASK = 0x00005060, + /* 0x54 ('T') for test handlers */ + TEST_TASK = 0x54694269, + LIBGPIOD_TEST = 0x54123456, + SPI_TEST = 0x54000010, + UART_TEST = 0x54000020, + DUMMY_INTERFACE = 0x5400CAFE, + DUMMY_HANDLER = 0x5400AFFE, + P60DOCK_TEST_TASK = 0x00005060, }; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 899aaf2b..03973790 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -120,236 +120,236 @@ const char *TM_FUNNEL_STRING = "TM_FUNNEL"; const char *CCSDS_IP_CORE_BRIDGE_STRING = "CCSDS_IP_CORE_BRIDGE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; -const char* translateObject(object_id_t object) { - switch( (object & 0xFFFFFFFF) ) { - case 0x00005060: - return P60DOCK_TEST_TASK_STRING; - case 0x43000003: - return CORE_CONTROLLER_STRING; - case 0x43100002: - return ACS_CONTROLLER_STRING; - case 0x43400001: - return THERMAL_CONTROLLER_STRING; - case 0x44120006: - return MGM_0_LIS3_HANDLER_STRING; - case 0x44120010: - return GYRO_0_ADIS_HANDLER_STRING; - case 0x44120032: - return SUS_1_STRING; - case 0x44120033: - return SUS_2_STRING; - case 0x44120034: - return SUS_3_STRING; - case 0x44120035: - return SUS_4_STRING; - case 0x44120036: - return SUS_5_STRING; - case 0x44120037: - return SUS_6_STRING; - case 0x44120038: - return SUS_7_STRING; - case 0x44120039: - return SUS_8_STRING; - case 0x44120040: - return SUS_9_STRING; - case 0x44120041: - return SUS_10_STRING; - case 0x44120042: - return SUS_11_STRING; - case 0x44120043: - return SUS_12_STRING; - case 0x44120044: - return SUS_13_STRING; - case 0x44120047: - return RW1_STRING; - case 0x44120107: - return MGM_1_RM3100_HANDLER_STRING; - case 0x44120111: - return GYRO_1_L3G_HANDLER_STRING; - case 0x44120148: - return RW2_STRING; - case 0x44120208: - return MGM_2_LIS3_HANDLER_STRING; - case 0x44120212: - return GYRO_2_ADIS_HANDLER_STRING; - case 0x44120249: - return RW3_STRING; - case 0x44120309: - return MGM_3_RM3100_HANDLER_STRING; - case 0x44120313: - return GYRO_3_L3G_HANDLER_STRING; - case 0x44120350: - return RW4_STRING; - case 0x44130001: - return STAR_TRACKER_STRING; - case 0x44130045: - return GPS0_HANDLER_STRING; - case 0x44130146: - return GPS1_HANDLER_STRING; - case 0x44140014: - return IMTQ_HANDLER_STRING; - case 0x442000A1: - return PCDU_HANDLER_STRING; - case 0x44250000: - return P60DOCK_HANDLER_STRING; - case 0x44250001: - return PDU1_HANDLER_STRING; - case 0x44250002: - return PDU2_HANDLER_STRING; - case 0x44250003: - return ACU_HANDLER_STRING; - case 0x443200A5: - return RAD_SENSOR_STRING; - case 0x44330000: - return PLOC_UPDATER_STRING; - case 0x44330001: - return PLOC_MEMORY_DUMPER_STRING; - case 0x44330002: - return STR_HELPER_STRING; - case 0x44330015: - return PLOC_MPSOC_HANDLER_STRING; - case 0x44330016: - return PLOC_SUPERVISOR_HANDLER_STRING; - case 0x444100A2: - return SOLAR_ARRAY_DEPL_HANDLER_STRING; - case 0x444100A4: - return HEATER_HANDLER_STRING; - case 0x44420004: - return TMP1075_HANDLER_1_STRING; - case 0x44420005: - return TMP1075_HANDLER_2_STRING; - case 0x44420016: - return RTD_IC_3_STRING; - case 0x44420017: - return RTD_IC_4_STRING; - case 0x44420018: - return RTD_IC_5_STRING; - case 0x44420019: - return RTD_IC_6_STRING; - case 0x44420020: - return RTD_IC_7_STRING; - case 0x44420021: - return RTD_IC_8_STRING; - case 0x44420022: - return RTD_IC_9_STRING; - case 0x44420023: - return RTD_IC_10_STRING; - case 0x44420024: - return RTD_IC_11_STRING; - case 0x44420025: - return RTD_IC_12_STRING; - case 0x44420026: - return RTD_IC_13_STRING; - case 0x44420027: - return RTD_IC_14_STRING; - case 0x44420028: - return RTD_IC_15_STRING; - case 0x44420029: - return RTD_IC_16_STRING; - case 0x44420030: - return RTD_IC_17_STRING; - case 0x44420031: - return RTD_IC_18_STRING; - case 0x445300A3: - return SYRLINKS_HK_HANDLER_STRING; - case 0x49000000: - return ARDUINO_COM_IF_STRING; - case 0x49010005: - return GPIO_IF_STRING; - case 0x49020004: - return SPI_COM_IF_STRING; - case 0x49030003: - return UART_COM_IF_STRING; - case 0x49040002: - return I2C_COM_IF_STRING; - case 0x49050001: - return CSP_COM_IF_STRING; - case 0x50000100: - return CCSDS_PACKET_DISTRIBUTOR_STRING; - case 0x50000200: - return PUS_PACKET_DISTRIBUTOR_STRING; - case 0x50000300: - return TMTC_BRIDGE_STRING; - case 0x50000400: - return TMTC_POLLING_TASK_STRING; - case 0x50000500: - return FILE_SYSTEM_HANDLER_STRING; - case 0x50000600: - return PTME_STRING; - case 0x50000700: - return PAPB_VC0_STRING; - case 0x50000701: - return PAPB_VC1_STRING; - case 0x50000702: - return PAPB_VC2_STRING; - case 0x50000703: - return PAPB_VC3_STRING; - case 0x50000704: - return PDEC_HANDLER_STRING; - case 0x50000800: - return CCSDS_HANDLER_STRING; - case 0x51000500: - return PUS_SERVICE_6_STRING; - case 0x53000000: - return FSFW_OBJECTS_START_STRING; - case 0x53000001: - return PUS_SERVICE_1_VERIFICATION_STRING; - case 0x53000002: - return PUS_SERVICE_2_DEVICE_ACCESS_STRING; - case 0x53000003: - return PUS_SERVICE_3_HOUSEKEEPING_STRING; - case 0x53000005: - return PUS_SERVICE_5_EVENT_REPORTING_STRING; - case 0x53000008: - return PUS_SERVICE_8_FUNCTION_MGMT_STRING; - case 0x53000009: - return PUS_SERVICE_9_TIME_MGMT_STRING; - case 0x53000017: - return PUS_SERVICE_17_TEST_STRING; - case 0x53000020: - return PUS_SERVICE_20_PARAMETERS_STRING; - case 0x53000200: - return PUS_SERVICE_200_MODE_MGMT_STRING; - case 0x53000201: - return PUS_SERVICE_201_HEALTH_STRING; - case 0x53010000: - return HEALTH_TABLE_STRING; - case 0x53010100: - return MODE_STORE_STRING; - case 0x53030000: - return EVENT_MANAGER_STRING; - case 0x53040000: - return INTERNAL_ERROR_REPORTER_STRING; - case 0x534f0100: - return TC_STORE_STRING; - case 0x534f0200: - return TM_STORE_STRING; - case 0x534f0300: - return IPC_STORE_STRING; - case 0x53500010: - return TIME_STAMPER_STRING; - case 0x53ffffff: - return FSFW_OBJECTS_END_STRING; - case 0x54000010: - return SPI_TEST_STRING; - case 0x54000020: - return UART_TEST_STRING; - case 0x5400AFFE: - return DUMMY_HANDLER_STRING; - case 0x5400CAFE: - return DUMMY_INTERFACE_STRING; - case 0x54123456: - return LIBGPIOD_TEST_STRING; - case 0x54694269: - return TEST_TASK_STRING; - case 0x73000100: - return TM_FUNNEL_STRING; - case 0x73500000: - return CCSDS_IP_CORE_BRIDGE_STRING; - case 0xFFFFFFFF: - return NO_OBJECT_STRING; - default: - return "UNKNOWN_OBJECT"; - } - return 0; +const char *translateObject(object_id_t object) { + switch ((object & 0xFFFFFFFF)) { + case 0x00005060: + return P60DOCK_TEST_TASK_STRING; + case 0x43000003: + return CORE_CONTROLLER_STRING; + case 0x43100002: + return ACS_CONTROLLER_STRING; + case 0x43400001: + return THERMAL_CONTROLLER_STRING; + case 0x44120006: + return MGM_0_LIS3_HANDLER_STRING; + case 0x44120010: + return GYRO_0_ADIS_HANDLER_STRING; + case 0x44120032: + return SUS_1_STRING; + case 0x44120033: + return SUS_2_STRING; + case 0x44120034: + return SUS_3_STRING; + case 0x44120035: + return SUS_4_STRING; + case 0x44120036: + return SUS_5_STRING; + case 0x44120037: + return SUS_6_STRING; + case 0x44120038: + return SUS_7_STRING; + case 0x44120039: + return SUS_8_STRING; + case 0x44120040: + return SUS_9_STRING; + case 0x44120041: + return SUS_10_STRING; + case 0x44120042: + return SUS_11_STRING; + case 0x44120043: + return SUS_12_STRING; + case 0x44120044: + return SUS_13_STRING; + case 0x44120047: + return RW1_STRING; + case 0x44120107: + return MGM_1_RM3100_HANDLER_STRING; + case 0x44120111: + return GYRO_1_L3G_HANDLER_STRING; + case 0x44120148: + return RW2_STRING; + case 0x44120208: + return MGM_2_LIS3_HANDLER_STRING; + case 0x44120212: + return GYRO_2_ADIS_HANDLER_STRING; + case 0x44120249: + return RW3_STRING; + case 0x44120309: + return MGM_3_RM3100_HANDLER_STRING; + case 0x44120313: + return GYRO_3_L3G_HANDLER_STRING; + case 0x44120350: + return RW4_STRING; + case 0x44130001: + return STAR_TRACKER_STRING; + case 0x44130045: + return GPS0_HANDLER_STRING; + case 0x44130146: + return GPS1_HANDLER_STRING; + case 0x44140014: + return IMTQ_HANDLER_STRING; + case 0x442000A1: + return PCDU_HANDLER_STRING; + case 0x44250000: + return P60DOCK_HANDLER_STRING; + case 0x44250001: + return PDU1_HANDLER_STRING; + case 0x44250002: + return PDU2_HANDLER_STRING; + case 0x44250003: + return ACU_HANDLER_STRING; + case 0x443200A5: + return RAD_SENSOR_STRING; + case 0x44330000: + return PLOC_UPDATER_STRING; + case 0x44330001: + return PLOC_MEMORY_DUMPER_STRING; + case 0x44330002: + return STR_HELPER_STRING; + case 0x44330015: + return PLOC_MPSOC_HANDLER_STRING; + case 0x44330016: + return PLOC_SUPERVISOR_HANDLER_STRING; + case 0x444100A2: + return SOLAR_ARRAY_DEPL_HANDLER_STRING; + case 0x444100A4: + return HEATER_HANDLER_STRING; + case 0x44420004: + return TMP1075_HANDLER_1_STRING; + case 0x44420005: + return TMP1075_HANDLER_2_STRING; + case 0x44420016: + return RTD_IC_3_STRING; + case 0x44420017: + return RTD_IC_4_STRING; + case 0x44420018: + return RTD_IC_5_STRING; + case 0x44420019: + return RTD_IC_6_STRING; + case 0x44420020: + return RTD_IC_7_STRING; + case 0x44420021: + return RTD_IC_8_STRING; + case 0x44420022: + return RTD_IC_9_STRING; + case 0x44420023: + return RTD_IC_10_STRING; + case 0x44420024: + return RTD_IC_11_STRING; + case 0x44420025: + return RTD_IC_12_STRING; + case 0x44420026: + return RTD_IC_13_STRING; + case 0x44420027: + return RTD_IC_14_STRING; + case 0x44420028: + return RTD_IC_15_STRING; + case 0x44420029: + return RTD_IC_16_STRING; + case 0x44420030: + return RTD_IC_17_STRING; + case 0x44420031: + return RTD_IC_18_STRING; + case 0x445300A3: + return SYRLINKS_HK_HANDLER_STRING; + case 0x49000000: + return ARDUINO_COM_IF_STRING; + case 0x49010005: + return GPIO_IF_STRING; + case 0x49020004: + return SPI_COM_IF_STRING; + case 0x49030003: + return UART_COM_IF_STRING; + case 0x49040002: + return I2C_COM_IF_STRING; + case 0x49050001: + return CSP_COM_IF_STRING; + case 0x50000100: + return CCSDS_PACKET_DISTRIBUTOR_STRING; + case 0x50000200: + return PUS_PACKET_DISTRIBUTOR_STRING; + case 0x50000300: + return TMTC_BRIDGE_STRING; + case 0x50000400: + return TMTC_POLLING_TASK_STRING; + case 0x50000500: + return FILE_SYSTEM_HANDLER_STRING; + case 0x50000600: + return PTME_STRING; + case 0x50000700: + return PAPB_VC0_STRING; + case 0x50000701: + return PAPB_VC1_STRING; + case 0x50000702: + return PAPB_VC2_STRING; + case 0x50000703: + return PAPB_VC3_STRING; + case 0x50000704: + return PDEC_HANDLER_STRING; + case 0x50000800: + return CCSDS_HANDLER_STRING; + case 0x51000500: + return PUS_SERVICE_6_STRING; + case 0x53000000: + return FSFW_OBJECTS_START_STRING; + case 0x53000001: + return PUS_SERVICE_1_VERIFICATION_STRING; + case 0x53000002: + return PUS_SERVICE_2_DEVICE_ACCESS_STRING; + case 0x53000003: + return PUS_SERVICE_3_HOUSEKEEPING_STRING; + case 0x53000005: + return PUS_SERVICE_5_EVENT_REPORTING_STRING; + case 0x53000008: + return PUS_SERVICE_8_FUNCTION_MGMT_STRING; + case 0x53000009: + return PUS_SERVICE_9_TIME_MGMT_STRING; + case 0x53000017: + return PUS_SERVICE_17_TEST_STRING; + case 0x53000020: + return PUS_SERVICE_20_PARAMETERS_STRING; + case 0x53000200: + return PUS_SERVICE_200_MODE_MGMT_STRING; + case 0x53000201: + return PUS_SERVICE_201_HEALTH_STRING; + case 0x53010000: + return HEALTH_TABLE_STRING; + case 0x53010100: + return MODE_STORE_STRING; + case 0x53030000: + return EVENT_MANAGER_STRING; + case 0x53040000: + return INTERNAL_ERROR_REPORTER_STRING; + case 0x534f0100: + return TC_STORE_STRING; + case 0x534f0200: + return TM_STORE_STRING; + case 0x534f0300: + return IPC_STORE_STRING; + case 0x53500010: + return TIME_STAMPER_STRING; + case 0x53ffffff: + return FSFW_OBJECTS_END_STRING; + case 0x54000010: + return SPI_TEST_STRING; + case 0x54000020: + return UART_TEST_STRING; + case 0x5400AFFE: + return DUMMY_HANDLER_STRING; + case 0x5400CAFE: + return DUMMY_INTERFACE_STRING; + case 0x54123456: + return LIBGPIOD_TEST_STRING; + case 0x54694269: + return TEST_TASK_STRING; + case 0x73000100: + return TM_FUNNEL_STRING; + case 0x73500000: + return CCSDS_IP_CORE_BRIDGE_STRING; + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; } diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 82748821..814e5c2d 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -1,792 +1,730 @@ #include "pollingSequenceFactory.h" -#include "linux/devices/SusHandler.h" -#include "OBSWConfig.h" +#include #include #include -#include #include + +#include "OBSWConfig.h" +#include "linux/devices/SusHandler.h" #include "objects/systemObjectList.h" +ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) { + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); -ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) -{ - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; - } - - sif::error << "PollingSequence::initialize has errors!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + sif::error << "PollingSequence::initialize has errors!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { - uint32_t length = thisSequence->getPeriodMs(); - static_cast(length); + uint32_t length = thisSequence->getPeriodMs(); + static_cast(length); #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RTD_IC_18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_5, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_6, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_7, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_8, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_9, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_10, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_11, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_12, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_13, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_14, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_15, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_16, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_17, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RTD_IC_18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.6, DeviceHandlerIF::SEND_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TMP_DEVICES == 1 - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RTD_DEVICES == 1 - thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_6, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_7, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_8, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_9, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_10, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_11, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_12, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_16, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_17, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RTD_IC_18, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_3, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_5, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_6, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_7, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_8, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_9, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_10, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_11, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_12, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_13, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_14, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_15, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_16, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_17, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RTD_IC_18, length * 0.8, DeviceHandlerIF::GET_READ); #endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_RAD_SENSORS == 1 - /* Radiation sensor */ - thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + /* Radiation sensor */ + thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_SUN_SENSORS == 1 - /** - * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all - * requests to a sun sensor must be performed consecutively. Another reason for calling multiple - * device handler cycles is that the ADC conversions take some time. Thus first the ADC - * conversions are initiated and in a next step the results can be read from the internal FIFO. - * One sun sensor communication sequence also blocks the SPI bus. So other devices can not be - * inserted between the device handler cycles of one SUS. - */ - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); + /** + * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all + * requests to a sun sensor must be performed consecutively. Another reason for calling multiple + * device handler cycles is that the ADC conversions take some time. Thus first the ADC + * conversions are initiated and in a next step the results can be read from the internal FIFO. + * One sun sensor communication sequence also blocks the SPI bus. So other devices can not be + * inserted between the device handler cycles of one SUS. + */ + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); - /* Read ADC conversions from inernal FIFO */ - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); + /* Read ADC conversions from inernal FIFO */ + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); - /* Write setup */ - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); - /* Start ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); - /* Read ADC conversions */ - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); + /* Start ADC conversions */ + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); + /* Read ADC conversions */ + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_RW == 1 - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.5, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.65, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_ACS_BOARD == 1 - bool enableAside = true; - bool enableBside = false; - if(enableAside) { - // A side - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.7, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + bool enableAside = true; + bool enableBside = false; + if (enableAside) { + // A side + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.25, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.25, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.35, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); - } + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); + } - if(enableBside) { - // B side - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.7, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + if (enableBside) { + // B side + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.25, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.25, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.35, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.75, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.85, - DeviceHandlerIF::GET_READ); - } + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.35, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); + } #endif /* OBSW_ADD_ACS_BOARD == 1 */ - ReturnValue_t seqCheck = thisSequence->checkSequence(); - if (seqCheck != HasReturnvaluesIF::RETURN_OK) { - if(seqCheck == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { - sif::warning << "SPI PST is empty.." << std::endl; - } - else { - sif::error << "SPI PST initialization failed" << std::endl; - } - - return seqCheck; + ReturnValue_t seqCheck = thisSequence->checkSequence(); + if (seqCheck != HasReturnvaluesIF::RETURN_OK) { + if (seqCheck == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::warning << "SPI PST is empty.." << std::endl; + } else { + sif::error << "SPI PST initialization failed" << std::endl; } - return HasReturnvaluesIF::RETURN_OK; + + return seqCheck; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "I2C PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "I2C PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { - // Length of a communication cycle - uint32_t length = thisSequence->getPeriodMs(); - bool uartPstEmpty = true; + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + bool uartPstEmpty = true; #if OBSW_ADD_PLOC_MPSOC == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); #if OBSW_ADD_PLOC_SUPERVISOR == 1 - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_SYRLINKS == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_STAR_TRACKER == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::STAR_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); + uartPstEmpty = false; + thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::STAR_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - if(uartPstEmpty) { - return HasReturnvaluesIF::RETURN_OK; - } - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "UART PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + if (uartPstEmpty) { return HasReturnvaluesIF::RETURN_OK; + } + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "UART PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence){ - uint32_t length = thisSequence->getPeriodMs(); +ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) { + uint32_t length = thisSequence->getPeriodMs(); - // PCDU handlers receives two messages and both must be handled - thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // PCDU handlers receives two messages and both must be handled + thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::P60DOCK_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::ACU_HANDLER, - length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "GomSpace PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomSpace PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { - /* Length of a communication cycle */ - uint32_t length = thisSequence->getPeriodMs(); - bool notEmpty = false; +ReturnValue_t pst::pstTest(FixedTimeslotTaskIF *thisSequence) { + /* Length of a communication cycle */ + uint32_t length = thisSequence->getPeriodMs(); + bool notEmpty = false; #if RPI_TEST_ADIS16507 == 1 - notEmpty = true; - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + notEmpty = true; + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if RPI_TEST_GPS_HANDLER == 1 - notEmpty = true; - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + notEmpty = true; + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); #endif - static_cast(length); - if(not notEmpty) { - return HasReturnvaluesIF::RETURN_FAILED; - } - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Test PST initialization failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + static_cast(length); + if (not notEmpty) { + return HasReturnvaluesIF::RETURN_FAILED; + } + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Test PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } #if BOARD_TE0720 == 1 ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { - uint32_t length = thisSequence->getPeriodMs(); + uint32_t length = thisSequence->getPeriodMs(); #if TEST_PLOC_MPSOC_HANDLER == 1 - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 - thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if OBSW_TEST_SUS_HANDLER == 1 - /* Write setup */ - thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.903, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.904, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.905, DeviceHandlerIF::GET_READ); + /* Write setup */ + thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.903, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.904, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.905, DeviceHandlerIF::GET_READ); - /* Start conversion*/ - thisSequence->addSlot(objects::SUS_1, length * 0.906, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.907, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.908, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.909, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.91, DeviceHandlerIF::GET_READ); + /* Start conversion*/ + thisSequence->addSlot(objects::SUS_1, length * 0.906, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.907, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.908, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.909, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.91, DeviceHandlerIF::GET_READ); - /* Read conversions */ - thisSequence->addSlot(objects::SUS_1, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::SUS_1, length * 0.912, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.913, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::SUS_1, length * 0.914, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); + /* Read conversions */ + thisSequence->addSlot(objects::SUS_1, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SUS_1, length * 0.912, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.913, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SUS_1, length * 0.914, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); #endif #if OBSW_ADD_PLOC_SUPERVISOR == 1 - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Initialization of TE0720 PST failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Initialization of TE0720 PST failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } #endif /* BOARD_TE0720 == 1 */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 5bb5ff2a..36b86ba8 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -32,7 +32,7 @@ class FixedTimeslotTaskIF; namespace pst { /* 0.4 second period init*/ -ReturnValue_t pstGpio(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGpio(FixedTimeslotTaskIF* thisSequence); /** * @brief This function creates the PST for all gomspace devices. @@ -40,7 +40,7 @@ ReturnValue_t pstGpio(FixedTimeslotTaskIF *thisSequence); * Scheduled in a separate PST because the gomspace library uses blocking calls when requesting * data from devices. */ -ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pstUart(FixedTimeslotTaskIF* thisSequence); @@ -62,7 +62,6 @@ ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pollingSequenceTE0720(FixedTimeslotTaskIF* thisSequence); #endif -} - +} // namespace pst #endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/linux/fsfwconfig/returnvalues/classIds.h b/linux/fsfwconfig/returnvalues/classIds.h index b98801e2..86edb85f 100644 --- a/linux/fsfwconfig/returnvalues/classIds.h +++ b/linux/fsfwconfig/returnvalues/classIds.h @@ -1,8 +1,8 @@ #ifndef FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ #define FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ -#include #include +#include /** * Source IDs starts at 73 for now @@ -11,13 +11,12 @@ */ namespace CLASS_ID { enum { - CLASS_ID_START = COMMON_CLASS_ID_END, - SA_DEPL_HANDLER, //SADPL - SD_CARD_MANAGER, //SDMA - SCRATCH_BUFFER, //SCBU - CLASS_ID_END // [EXPORT] : [END] + CLASS_ID_START = COMMON_CLASS_ID_END, + SA_DEPL_HANDLER, // SADPL + SD_CARD_MANAGER, // SDMA + SCRATCH_BUFFER, // SCBU + CLASS_ID_END // [EXPORT] : [END] }; } - #endif /* FSFWCONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/linux/fsfwconfig/tmtc/pusIds.h b/linux/fsfwconfig/tmtc/pusIds.h index a2dd7575..37503786 100644 --- a/linux/fsfwconfig/tmtc/pusIds.h +++ b/linux/fsfwconfig/tmtc/pusIds.h @@ -2,21 +2,21 @@ #define CONFIG_TMTC_PUSIDS_HPP_ namespace pus { -enum Ids{ - PUS_SERVICE_1 = 1, - PUS_SERVICE_2 = 2, - PUS_SERVICE_3 = 3, - PUS_SERVICE_3_PSB = 3, - PUS_SERVICE_5 = 5, - PUS_SERVICE_6 = 6, - PUS_SERVICE_8 = 8, - PUS_SERVICE_9 = 9, - PUS_SERVICE_17 = 17, - PUS_SERVICE_19 = 19, - PUS_SERVICE_20 = 20, - PUS_SERVICE_23 = 23, - PUS_SERVICE_200 = 200, - PUS_SERVICE_201 = 201, +enum Ids { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_3_PSB = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, }; }; diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 5bb72066..f144306c 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -1,104 +1,98 @@ #include + #include "fsfw/serviceinterface/ServiceInterface.h" PapbVcInterface::PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, - gpioId_t papbBusyId, gpioId_t papbEmptyId, uint32_t vcOffset) : - SystemObject(objectId), gpioComIF(gpioComIF), papbBusyId( - papbBusyId), papbEmptyId(papbEmptyId), vcOffset(vcOffset) { -} - -PapbVcInterface::~PapbVcInterface() { -} + gpioId_t papbBusyId, gpioId_t papbEmptyId, uint32_t vcOffset) + : SystemObject(objectId), + gpioComIF(gpioComIF), + papbBusyId(papbBusyId), + papbEmptyId(papbEmptyId), + vcOffset(vcOffset) {} +PapbVcInterface::~PapbVcInterface() {} void PapbVcInterface::setRegisterAddress(uint32_t* ptmeBaseAddress) { - vcBaseReg = ptmeBaseAddress + vcOffset; + vcBaseReg = ptmeBaseAddress + vcOffset; } -ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t size) { +ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } - if(pollPapbBusySignal() == RETURN_OK) { - startPacketTransfer(); + for (size_t idx = 0; idx < size; idx++) { + if (pollPapbBusySignal() == RETURN_OK) { + *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); + } else { + sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size << " data" + << std::endl; + return RETURN_FAILED; } + } - for(size_t idx = 0; idx < size; idx++) { - if(pollPapbBusySignal() == RETURN_OK) { - *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); - } - else { - sif::warning << "PapbVcInterface::write: Only written " << idx << " of " - << size << " data" << std::endl; - return RETURN_FAILED; - } - } - - if(pollPapbBusySignal() == RETURN_OK) { - endPacketTransfer(); - } - return RETURN_OK; + if (pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + return RETURN_OK; } -void PapbVcInterface::startPacketTransfer() { - *vcBaseReg = CONFIG_START; -} +void PapbVcInterface::startPacketTransfer() { *vcBaseReg = CONFIG_START; } -void PapbVcInterface::endPacketTransfer() { - *vcBaseReg = CONFIG_END; -} +void PapbVcInterface::endPacketTransfer() { *vcBaseReg = CONFIG_END; } ReturnValue_t PapbVcInterface::pollPapbBusySignal() { - int papbBusyState = 0; - ReturnValue_t result = RETURN_OK; + int papbBusyState = 0; + ReturnValue_t result = RETURN_OK; - /** Check if PAPB interface is ready to receive data */ - result = gpioComIF->readGpio(papbBusyId, &papbBusyState); - if (result != RETURN_OK) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" - << std::endl; - return RETURN_FAILED; - } - if (!papbBusyState) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; - return PAPB_BUSY; - } + /** Check if PAPB interface is ready to receive data */ + result = gpioComIF->readGpio(papbBusyId, &papbBusyState); + if (result != RETURN_OK) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } - return RETURN_OK; + return RETURN_OK; } void PapbVcInterface::isVcInterfaceBufferEmpty() { - ReturnValue_t result = RETURN_OK; - int papbEmptyState = 1; + ReturnValue_t result = RETURN_OK; + int papbEmptyState = 1; - result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); + result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); - if (result != RETURN_OK) { - sif::warning << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" - << std::endl; - return; - } - - if (papbEmptyState == 1) { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; - } - else { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; - } + if (result != RETURN_OK) { + sif::warning << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" + << std::endl; return; + } + + if (papbEmptyState == 1) { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; + } else { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; + } + return; } ReturnValue_t PapbVcInterface::sendTestFrame() { - /** Size of one complete transfer frame data field amounts to 1105 bytes */ - uint8_t testPacket[1105]; + /** Size of one complete transfer frame data field amounts to 1105 bytes */ + uint8_t testPacket[1105]; - /** Fill one test packet */ - for(int idx = 0; idx < 1105; idx++) { - testPacket[idx] = static_cast(idx & 0xFF); - } + /** Fill one test packet */ + for (int idx = 0; idx < 1105; idx++) { + testPacket[idx] = static_cast(idx & 0xFF); + } - ReturnValue_t result = write(testPacket, 1105); - if(result != RETURN_OK) { - return result; - } + ReturnValue_t result = write(testPacket, 1105); + if (result != RETURN_OK) { + return result; + } - return RETURN_OK; + return RETURN_OK; } diff --git a/linux/obc/PapbVcInterface.h b/linux/obc/PapbVcInterface.h index 937f4280..e7d03a70 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -1,12 +1,13 @@ #ifndef LINUX_OBC_PAPBVCINTERFACE_H_ #define LINUX_OBC_PAPBVCINTERFACE_H_ -#include "OBSWConfig.h" -#include "linux/obc/VcInterfaceIF.h" #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +#include "OBSWConfig.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "linux/obc/VcInterfaceIF.h" /** * @brief This class handles the transmission of data to a virtual channel of the PTME IP Core @@ -14,99 +15,96 @@ * * @author J. Meier */ -class PapbVcInterface: public SystemObject, - public VcInterfaceIF, - public HasReturnvaluesIF { -public: - /** - * @brief Constructor - * - * @param objectId - * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the - * VcInterface IP Core. A low logic level indicates the VcInterface is not - * ready to receive more data. - * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the - * VcInterface IP Core. The signal is high when there are no packets in the - * external buffer memory (BRAM). - */ - PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, - gpioId_t papbEmptyId, uint32_t vcOffset); - virtual ~PapbVcInterface(); +class PapbVcInterface : public SystemObject, public VcInterfaceIF, public HasReturnvaluesIF { + public: + /** + * @brief Constructor + * + * @param objectId + * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the + * VcInterface IP Core. A low logic level indicates the VcInterface is not + * ready to receive more data. + * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the + * VcInterface IP Core. The signal is high when there are no packets in the + * external buffer memory (BRAM). + */ + PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, + gpioId_t papbEmptyId, uint32_t vcOffset); + virtual ~PapbVcInterface(); - ReturnValue_t write(const uint8_t* data, size_t size) override; + ReturnValue_t write(const uint8_t* data, size_t size) override; - void setRegisterAddress(uint32_t* ptmeBaseAddress) override; + void setRegisterAddress(uint32_t* ptmeBaseAddress) override; -private: + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; + static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t PAPB_BUSY = MAKE_RETURN_CODE(0xA0); + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to VcInterface the start of a new telemetry packet + */ + static const uint32_t CONFIG_START = 0x8; - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to VcInterface the start of a new telemetry packet - */ - static const uint32_t CONFIG_START = 0x8; + /** + * Writing this word to the VcInterface base address signals to the virtual channel interface + * that a complete tm packet has been transferred. + */ + static const uint32_t CONFIG_END = 0x0; - /** - * Writing this word to the VcInterface base address signals to the virtual channel interface - * that a complete tm packet has been transferred. - */ - static const uint32_t CONFIG_END = 0x0; + /** + * Writing to this offset within the memory space of a virtual channel will insert data for + * encoding to the external buffer memory of the PTME IP Core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int DATA_REG_OFFSET = 256; - /** - * Writing to this offset within the memory space of a virtual channel will insert data for - * encoding to the external buffer memory of the PTME IP Core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int DATA_REG_OFFSET = 256; + LinuxLibgpioIF* gpioComIF = nullptr; - LinuxLibgpioIF* gpioComIF = nullptr; + /** Pulled to low when virtual channel not ready to receive data */ + gpioId_t papbBusyId = gpio::NO_GPIO; + /** High when external buffer memory of virtual channel is empty */ + gpioId_t papbEmptyId = gpio::NO_GPIO; - /** Pulled to low when virtual channel not ready to receive data */ - gpioId_t papbBusyId = gpio::NO_GPIO; - /** High when external buffer memory of virtual channel is empty */ - gpioId_t papbEmptyId = gpio::NO_GPIO; + uint32_t* vcBaseReg = nullptr; - uint32_t* vcBaseReg = nullptr; + uint32_t vcOffset = 0; - uint32_t vcOffset = 0; + /** + * @brief This function sends the config byte to the virtual channel of the PTME IP Core + * to initiate a packet transfer. + */ + void startPacketTransfer(); - /** - * @brief This function sends the config byte to the virtual channel of the PTME IP Core - * to initiate a packet transfer. - */ - void startPacketTransfer(); + /** + * @brief This function sends the config byte to the virtual channel interface of the PTME + * IP Core to signal the end of a packet transfer. + */ + void endPacketTransfer(); - /** - * @brief This function sends the config byte to the virtual channel interface of the PTME - * IP Core to signal the end of a packet transfer. - */ - void endPacketTransfer(); + /** + * @brief This function reads the papb busy signal indicating whether the virtual channel + * interface is ready to receive more data or not. PAPB is ready when + * PAPB_Busy_N == '1'. + * + * @return RETURN_OK when ready to receive data else PAPB_BUSY. + */ + ReturnValue_t pollPapbBusySignal(); - /** - * @brief This function reads the papb busy signal indicating whether the virtual channel - * interface is ready to receive more data or not. PAPB is ready when - * PAPB_Busy_N == '1'. - * - * @return RETURN_OK when ready to receive data else PAPB_BUSY. - */ - ReturnValue_t pollPapbBusySignal(); + /** + * @brief This function can be used for debugging to check whether there are packets in + * the packet buffer of the virtual channel or not. + */ + void isVcInterfaceBufferEmpty(); - /** - * @brief This function can be used for debugging to check whether there are packets in - * the packet buffer of the virtual channel or not. - */ - void isVcInterfaceBufferEmpty(); - - /** - * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) - * to the papb interface of the PTME IP Core. Can be used to test the implementation. - */ - ReturnValue_t sendTestFrame(); + /** + * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) + * to the papb interface of the PTME IP Core. Can be used to test the implementation. + */ + ReturnValue_t sendTestFrame(); }; #endif /* LINUX_OBC_PAPBVCINTERFACE_H_ */ diff --git a/linux/obc/PdecConfig.cpp b/linux/obc/PdecConfig.cpp index bb2ffb13..ac762a6c 100644 --- a/linux/obc/PdecConfig.cpp +++ b/linux/obc/PdecConfig.cpp @@ -1,36 +1,33 @@ #include "PdecConfig.h" + #include "fsfw/serviceinterface/ServiceInterface.h" -PdecConfig::PdecConfig() { - initialize(); -} +PdecConfig::PdecConfig() { initialize(); } -PdecConfig::~PdecConfig() { - -} +PdecConfig::~PdecConfig() {} void PdecConfig::initialize() { - uint32_t word = 0; - word |= (VERSION_ID << 30); - word |= (BYPASS_FLAG << 29); - word |= (CONTROL_COMMAND_FLAG << 28); - word |= (RESERVED_FIELD_A << 26); - word |= (SPACECRAFT_ID << 16); - word |= (VIRTUAL_CHANNEL << 10); - word |= (DUMMY_BITS << 8); - word |= POSITIVE_WINDOW; - configWords[0] = word; - word = 0; - word |= (NEGATIVE_WINDOW << 24); - word |= (HIGH_AU_MAP_ID << 16); - word |= (ENABLE_DERANDOMIZER << 8); - configWords[1] = word; + uint32_t word = 0; + word |= (VERSION_ID << 30); + word |= (BYPASS_FLAG << 29); + word |= (CONTROL_COMMAND_FLAG << 28); + word |= (RESERVED_FIELD_A << 26); + word |= (SPACECRAFT_ID << 16); + word |= (VIRTUAL_CHANNEL << 10); + word |= (DUMMY_BITS << 8); + word |= POSITIVE_WINDOW; + configWords[0] = word; + word = 0; + word |= (NEGATIVE_WINDOW << 24); + word |= (HIGH_AU_MAP_ID << 16); + word |= (ENABLE_DERANDOMIZER << 8); + configWords[1] = word; } uint32_t PdecConfig::getConfigWord(uint8_t wordNo) { - if (wordNo >= CONFIG_WORDS_NUM) { - sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; - return 0; - } - return configWords[wordNo]; + if (wordNo >= CONFIG_WORDS_NUM) { + sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; + return 0; + } + return configWords[wordNo]; } diff --git a/linux/obc/PdecConfig.h b/linux/obc/PdecConfig.h index 46cd5097..37dab151 100644 --- a/linux/obc/PdecConfig.h +++ b/linux/obc/PdecConfig.h @@ -1,9 +1,10 @@ #ifndef LINUX_OBC_PDECCONFIG_H_ #define LINUX_OBC_PDECCONFIG_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + /** * @brief This class generates the configuration words for the configuration memory of the PDEC * IP Cores. @@ -14,39 +15,38 @@ * @author J. Meier */ class PdecConfig { + public: + PdecConfig(); + virtual ~PdecConfig(); -public: - PdecConfig(); - virtual ~PdecConfig(); + /** + * @brief Returns the configuration word by specifying the position. + */ + uint32_t getConfigWord(uint8_t wordNo); - /** - * @brief Returns the configuration word by specifying the position. - */ - uint32_t getConfigWord(uint8_t wordNo); + private: + // TC transfer frame configuration parameters + static const uint8_t VERSION_ID = 0; + // BD Frames + static const uint8_t BYPASS_FLAG = 1; + static const uint8_t CONTROL_COMMAND_FLAG = 0; -private: - // TC transfer frame configuration parameters - static const uint8_t VERSION_ID = 0; - // BD Frames - static const uint8_t BYPASS_FLAG = 1; - static const uint8_t CONTROL_COMMAND_FLAG = 0; + static const uint8_t VIRTUAL_CHANNEL = 0; + static const uint8_t RESERVED_FIELD_A = 0; + static const uint16_t SPACECRAFT_ID = 0x274; + static const uint16_t DUMMY_BITS = 0; + // Parameters to control the FARM for AD frames + // Set here for future use + static const uint8_t POSITIVE_WINDOW = 10; + static const uint8_t NEGATIVE_WINDOW = 151; + static const uint8_t HIGH_AU_MAP_ID = 0xF; + static const uint8_t ENABLE_DERANDOMIZER = 1; - static const uint8_t VIRTUAL_CHANNEL = 0; - static const uint8_t RESERVED_FIELD_A = 0; - static const uint16_t SPACECRAFT_ID = 0x274; - static const uint16_t DUMMY_BITS = 0; - // Parameters to control the FARM for AD frames - // Set here for future use - static const uint8_t POSITIVE_WINDOW = 10; - static const uint8_t NEGATIVE_WINDOW = 151; - static const uint8_t HIGH_AU_MAP_ID = 0xF; - static const uint8_t ENABLE_DERANDOMIZER = 1; + static const uint8_t CONFIG_WORDS_NUM = 2; - static const uint8_t CONFIG_WORDS_NUM = 2; + uint32_t configWords[CONFIG_WORDS_NUM]; - uint32_t configWords[CONFIG_WORDS_NUM]; - - void initialize(); + void initialize(); }; #endif /* LINUX_OBC_PDECCONFIG_H_ */ diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index aa46c23c..a5ee98d6 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,578 +1,568 @@ +#include "PdecHandler.h" + +#include +#include + #include #include -#include -#include - -#include "PdecHandler.h" #include "OBSWConfig.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/ipc/QueueFactory.h" - PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, - LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, - std::string uioRamMemory, std::string uioRegisters) : - SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset( - pdecReset), uioConfigMemory(uioConfigMemory), uioRamMemory(uioRamMemory), uioRegisters( - uioRegisters), actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, + std::string uioRamMemory, std::string uioRegisters) + : SystemObject(objectId), + tcDestinationId(tcDestinationId), + gpioComIF(gpioComIF), + pdecReset(pdecReset), + uioConfigMemory(uioConfigMemory), + uioRamMemory(uioRamMemory), + uioRegisters(uioRegisters), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); } -PdecHandler::~PdecHandler() { -} +PdecHandler::~PdecHandler() {} ReturnValue_t PdecHandler::initialize() { + tcStore = ObjectManager::instance()->get(objects::TC_STORE); + if (tcStore == nullptr) { + sif::error << "PdecHandler::initialize: Invalid TC store" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tcStore = ObjectManager::instance()->get(objects::TC_STORE); - if (tcStore == nullptr) { - sif::error << "PdecHandler::initialize: Invalid TC store" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + tcDestination = ObjectManager::instance()->get(tcDestinationId); - tcDestination = ObjectManager::instance()->get( - tcDestinationId); + if (tcDestination == nullptr) { + sif::error << "PdecHandler::initialize: Invalid tc destination specified" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if (tcDestination == nullptr) { - sif::error << "PdecHandler::initialize: Invalid tc destination specified" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = getRegisterAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getRegisterAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = getConfigMemoryBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getConfigMemoryBaseAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = getRamBaseAddress(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = getRamBaseAddress(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + writePdecConfig(); - writePdecConfig(); + result = releasePdec(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = releasePdec(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return result; - } - - return RETURN_OK; + return RETURN_OK; } -MessageQueueId_t PdecHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PdecHandler::getCommandQueue() const { return commandQueue->getId(); } ReturnValue_t PdecHandler::getRegisterAddress() { - int fd = open(uioRegisters.c_str(), O_RDWR); - if (fd < 1) { - sif::warning << "PdecHandler::getRegisterAddress: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } + int fd = open(uioRegisters.c_str(), O_RDWR); + if (fd < 1) { + sif::warning << "PdecHandler::getRegisterAddress: Invalid UIO device file" << std::endl; + return RETURN_FAILED; + } - registerBaseAddress = static_cast(mmap(NULL, REGISTER_MAP_SIZE, - PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); + registerBaseAddress = static_cast( + mmap(NULL, REGISTER_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); - if (registerBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getRegisterAddress: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } + if (registerBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getRegisterAddress: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PdecHandler::getConfigMemoryBaseAddress() { - int fd = open(uioConfigMemory.c_str(), O_RDWR); - if (fd < 1) { - sif::warning << "PdecHandler::getConfigMemoryBaseAddress: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } + int fd = open(uioConfigMemory.c_str(), O_RDWR); + if (fd < 1) { + sif::warning << "PdecHandler::getConfigMemoryBaseAddress: Invalid UIO device file" << std::endl; + return RETURN_FAILED; + } - memoryBaseAddress = static_cast(mmap(NULL, CONFIG_MEMORY_MAP_SIZE, PROT_WRITE | PROT_READ, - MAP_SHARED, fd, 0)); + memoryBaseAddress = static_cast( + mmap(NULL, CONFIG_MEMORY_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); - if (memoryBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getConfigMemoryBaseAddress: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } + if (memoryBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getConfigMemoryBaseAddress: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PdecHandler::getRamBaseAddress() { - int fd = open(uioRamMemory.c_str(), O_RDWR); + int fd = open(uioRamMemory.c_str(), O_RDWR); - ramBaseAddress = static_cast(mmap(NULL, RAM_MAP_SIZE, PROT_WRITE | PROT_READ, - MAP_SHARED, fd, 0)); + ramBaseAddress = + static_cast(mmap(NULL, RAM_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); - if (ramBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getRamBaseAddress: Failed to map RAM base address" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + if (ramBaseAddress == MAP_FAILED) { + sif::error << "PdecHandler::getRamBaseAddress: Failed to map RAM base address" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } -void PdecHandler::writePdecConfig() { +void PdecHandler::writePdecConfig() { + PdecConfig pdecConfig; - PdecConfig pdecConfig; + *(memoryBaseAddress + FRAME_HEADER_OFFSET) = pdecConfig.getConfigWord(0); + *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); - *(memoryBaseAddress + FRAME_HEADER_OFFSET)= pdecConfig.getConfigWord(0); - *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); + // Configure all MAP IDs as invalid + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = + NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + } - // Configure all MAP IDs as invalid - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = NO_DESTINATION << 24 - | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) + uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = + (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) | routeToPm; - } - - // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) - uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) - | routeToPm; - - // Write map id clock frequencies - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = MAP_CLK_FREQ << 24 - | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; - - } + // Write map id clock frequencies + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = + MAP_CLK_FREQ << 24 | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; + } } ReturnValue_t PdecHandler::resetFarStatFlag() { - uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); - if (pdecFar != FAR_RESET) { - sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." - << " Read value: 0x" << std::hex << static_cast(pdecFar) << std::endl; - return RETURN_FAILED; - } + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + if (pdecFar != FAR_RESET) { + sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value." + << " Read value: 0x" << std::hex << static_cast(pdecFar) + << std::endl; + return RETURN_FAILED; + } #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar - << std::endl; + sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar + << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */ - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t PdecHandler::releasePdec() { - ReturnValue_t result = RETURN_OK; - result = gpioComIF->pullHigh(pdecReset); - if (result != RETURN_OK) { - sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl; - } - return result; +ReturnValue_t PdecHandler::releasePdec() { + ReturnValue_t result = RETURN_OK; + result = gpioComIF->pullHigh(pdecReset); + if (result != RETURN_OK) { + sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl; + } + return result; } ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + readCommandQueue(); - readCommandQueue(); - - switch(state) { + switch (state) { case State::INIT: - resetFarStatFlag(); - if (result != RETURN_OK) { - // Requires reconfiguration and reinitialization of PDEC - triggerEvent(INVALID_FAR); - state = State::WAIT_FOR_RECOVERY; - return result; - } - state = State::RUNNING; - break; + resetFarStatFlag(); + if (result != RETURN_OK) { + // Requires reconfiguration and reinitialization of PDEC + triggerEvent(INVALID_FAR); + state = State::WAIT_FOR_RECOVERY; + return result; + } + state = State::RUNNING; + break; case State::RUNNING: - if (newTcReceived()) { - handleNewTc(); - } - checkLocks(); - break; + if (newTcReceived()) { + handleNewTc(); + } + checkLocks(); + break; case State::WAIT_FOR_RECOVERY: - break; + break; default: - sif::debug << "PdecHandler::performOperation: Invalid state" << std::endl; - break; - } + sif::debug << "PdecHandler::performOperation: Invalid state" << std::endl; + break; + } - return RETURN_OK; + return RETURN_OK; } void PdecHandler::readCommandQueue(void) { - CommandMessage commandMessage; - ReturnValue_t result = RETURN_FAILED; + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; - result = commandQueue->receiveMessage(&commandMessage); + result = commandQueue->receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = actionHelper.handleActionMessage(&commandMessage); if (result == RETURN_OK) { - result = actionHelper.handleActionMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, - commandMessage.getCommand()); - commandQueue->reply(&reply); - return; + return; } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + commandQueue->reply(&reply); + return; + } } bool PdecHandler::newTcReceived() { - uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); + uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET); - if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { - return false; - } - if (!checkFrameAna(pdecFar)) { - return false; - } - return true; + if (pdecFar >> STAT_POSITION != NEW_FAR_RECEIVED) { + return false; + } + if (!checkFrameAna(pdecFar)) { + return false; + } + return true; } void PdecHandler::checkLocks() { - uint32_t clcw = getClcw(); - if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) { - // Rf available changed from 0 to 1 - triggerEvent(CARRIER_LOCK); - } - if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { - // Bit lock changed from 0 to 1 - triggerEvent(BIT_LOCK_PDEC); - } - lastClcw = clcw; + uint32_t clcw = getClcw(); + if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) { + // Rf available changed from 0 to 1 + triggerEvent(CARRIER_LOCK); + } + if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) { + // Bit lock changed from 0 to 1 + triggerEvent(BIT_LOCK_PDEC); + } + lastClcw = clcw; } bool PdecHandler::checkFrameAna(uint32_t pdecFar) { - bool frameValid = false; - FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); - switch(frameAna) { - case(FrameAna_t::ABANDONED_CLTU): { - triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); - sif::warning << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; - break; + bool frameValid = false; + FrameAna_t frameAna = static_cast((pdecFar & FRAME_ANA_MASK) >> FRAME_ANA_POSITION); + switch (frameAna) { + case (FrameAna_t::ABANDONED_CLTU): { + triggerEvent(INVALID_TC_FRAME, ABANDONED_CLTU); + sif::warning << "PdecHandler::checkFrameAna: Abondoned CLTU" << std::endl; + break; } - case(FrameAna_t::FRAME_DIRTY): { - triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); - sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; - break; + case (FrameAna_t::FRAME_DIRTY): { + triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY); + sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; + break; } - case(FrameAna_t::FRAME_ILLEGAL): { - sif::warning << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; - handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); - break; + case (FrameAna_t::FRAME_ILLEGAL): { + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for one reason" << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_ONE_REASON); + break; } - case(FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { - sif::warning << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" - << std::endl; - handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); - break; + case (FrameAna_t::FRAME_ILLEGAL_MULTI_REASON): { + sif::warning << "PdecHandler::checkFrameAna: Frame illegal for multiple reasons" << std::endl; + handleIReason(pdecFar, FRAME_ILLEGAL_MULTIPLE_REASONS); + break; } - case(FrameAna_t::AD_DISCARDED_LOCKOUT): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_LOCKOUT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of lockout" + << std::endl; + break; } - case(FrameAna_t::AD_DISCARDED_WAIT): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of wait" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_WAIT): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_LOCKOUT); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because of wait" << std::endl; + break; } - case(FrameAna_t::AD_DISCARDED_NS_VR): { - triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); - sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" - << std::endl; - break; + case (FrameAna_t::AD_DISCARDED_NS_VR): { + triggerEvent(INVALID_TC_FRAME, AD_DISCARDED_NS_VS); + sif::warning << "PdecHandler::checkFrameAna: AD frame discarded because N(S) or V(R)" + << std::endl; + break; } - case(FrameAna_t::FRAME_ACCEPTED): { + case (FrameAna_t::FRAME_ACCEPTED): { #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::info << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; + sif::info << "PdecHandler::checkFrameAna: Accepted TC frame" << std::endl; #endif - frameValid = true; - break; + frameValid = true; + break; } default: { - sif::debug << "PdecHandler::checkFrameAna: Invalid frame analysis report" << std::endl; - break; + sif::debug << "PdecHandler::checkFrameAna: Invalid frame analysis report" << std::endl; + break; } - } - return frameValid; + } + return frameValid; } void PdecHandler::handleIReason(uint32_t pdecFar, ReturnValue_t parameter1) { - IReason_t ireason = static_cast((pdecFar & IREASON_MASK) >> IREASON_POSITION); - switch(ireason) { - case(IReason_t::NO_REPORT): { - triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); - sif::info << "PdecHandler::handleIReason: No illegal report" << std::endl; - break; + IReason_t ireason = static_cast((pdecFar & IREASON_MASK) >> IREASON_POSITION); + switch (ireason) { + case (IReason_t::NO_REPORT): { + triggerEvent(INVALID_TC_FRAME, parameter1, NO_REPORT); + sif::info << "PdecHandler::handleIReason: No illegal report" << std::endl; + break; } - case(IReason_t::ERROR_VERSION_NUMBER): { - triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); - sif::info << "PdecHandler::handleIReason: Error in version number and reserved A and B " + case (IReason_t::ERROR_VERSION_NUMBER): { + triggerEvent(INVALID_TC_FRAME, parameter1, ERROR_VERSION_NUMBER); + sif::info << "PdecHandler::handleIReason: Error in version number and reserved A and B " << "fields" << std::endl; - break; + break; } - case(IReason_t::ILLEGAL_COMBINATION): { - triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); - sif::info << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " + case (IReason_t::ILLEGAL_COMBINATION): { + triggerEvent(INVALID_TC_FRAME, parameter1, ILLEGAL_COMBINATION); + sif::info << "PdecHandler::handleIReason: Illegal combination (AC) of bypass and control " << "command flags" << std::endl; - break; + break; } - case(IReason_t::INVALID_SC_ID): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); - sif::info << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; - break; + case (IReason_t::INVALID_SC_ID): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_SC_ID); + sif::info << "PdecHandler::handleIReason: Invalid spacecraft identifier " << std::endl; + break; } - case(IReason_t::INVALID_VC_ID_MSB): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); - sif::info << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " + case (IReason_t::INVALID_VC_ID_MSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_MSB); + sif::info << "PdecHandler::handleIReason: VC identifier bit 0 to 4 did not match " << std::endl; - break; + break; } - case(IReason_t::INVALID_VC_ID_LSB): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); - sif::info << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; - break; + case (IReason_t::INVALID_VC_ID_LSB): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_VC_ID_LSB); + sif::info << "PdecHandler::handleIReason: VC identifier bit 5 did not match " << std::endl; + break; } - case(IReason_t::NS_NOT_ZERO): { - triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); - sif::info << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" + case (IReason_t::NS_NOT_ZERO): { + triggerEvent(INVALID_TC_FRAME, parameter1, NS_NOT_ZERO); + sif::info << "PdecHandler::handleIReason: N(S) of BC or BD frame not set to all zeros" << std::endl; - break; + break; } - case(IReason_t::INCORRECT_BC_CC): { - triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); - sif::info << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; - break; + case (IReason_t::INCORRECT_BC_CC): { + triggerEvent(INVALID_TC_FRAME, parameter1, INVALID_BC_CC); + sif::info << "PdecHandler::handleIReason: Invalid BC control command format" << std::endl; + break; } default: { - sif::info << "PdecHandler::handleIReason: Invalid reason id" << std::endl; - break; - } + sif::info << "PdecHandler::handleIReason: Invalid reason id" << std::endl; + break; } + } } void PdecHandler::handleNewTc() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - uint32_t tcLength = 0; - result = readTc(tcLength); - if (result != RETURN_OK) { - return; - } + uint32_t tcLength = 0; + result = readTc(tcLength); + if (result != RETURN_OK) { + return; + } #if OBSW_DEBUG_PDEC_HANDLER == 1 - unsigned int mapId = tcSegment[0] & MAP_ID_MASK; - sif::info << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId - << std::endl; - printTC(tcLength); + unsigned int mapId = tcSegment[0] & MAP_ID_MASK; + sif::info << "PdecHandler::handleNewTc: Received TC segment with map ID " << mapId << std::endl; + printTC(tcLength); #endif /* OBSW_DEBUG_PDEC_HANDLER */ - store_address_t storeId; - result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); - if (result != RETURN_OK) { - sif::warning << "PdecHandler::handleNewTc: Failed to add received space packet to store" - << std::endl; - return; - } - - TmTcMessage message(storeId); - - result = MessageQueueSenderIF::sendMessage(tcDestination->getRequestQueue(), &message); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "PdecHandler::handleNewTc: Failed to send message to TC destination" - << std::endl; - tcStore->deleteData(storeId); - return; - } - + store_address_t storeId; + result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); + if (result != RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to add received space packet to store" + << std::endl; return; + } + + TmTcMessage message(storeId); + + result = MessageQueueSenderIF::sendMessage(tcDestination->getRequestQueue(), &message); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "PdecHandler::handleNewTc: Failed to send message to TC destination" + << std::endl; + tcStore->deleteData(storeId); + return; + } + + return; } ReturnValue_t PdecHandler::readTc(uint32_t& tcLength) { - uint32_t tcOffset = (*(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_RAM_BASE_ADDRESS) / 4; + uint32_t tcOffset = (*(registerBaseAddress + PDEC_BPTR_OFFSET) - PHYSICAL_RAM_BASE_ADDRESS) / 4; #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::readTc: TC offset: 0x" << std::hex << tcOffset << std::endl; + sif::debug << "PdecHandler::readTc: TC offset: 0x" << std::hex << tcOffset << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER */ - tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); + tcLength = *(registerBaseAddress + PDEC_SLEN_OFFSET); #if OBSW_DEBUG_PDEC_HANDLER == 1 - sif::debug << "PdecHandler::readTc: TC segment length: " << std::dec << tcLength << std::endl; + sif::debug << "PdecHandler::readTc: TC segment length: " << std::dec << tcLength << std::endl; #endif /* OBSW_DEBUG_PDEC_HANDLER */ - if (tcLength > MAX_TC_SEGMENT_SIZE) { - sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" - << std::endl; - return RETURN_FAILED; + if (tcLength > MAX_TC_SEGMENT_SIZE) { + sif::warning << "PdecHandler::handleNewTc: Read invalid TC length from PDEC register" + << std::endl; + return RETURN_FAILED; + } + + uint32_t idx = 0; + uint32_t tcData = 0; + for (idx = 0; idx <= tcLength; idx = idx + 4) { + tcData = *(ramBaseAddress + tcOffset + idx / 4); + if (idx == 0) { + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); + } else if (tcLength - idx + 1 == 3) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + } else if (tcLength - idx + 1 == 2) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + } else if (tcLength - idx + 1 == 1) { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + } else { + tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); + tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); + tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); + tcSegment[idx + 2] = static_cast(tcData & 0xFF); } + } - uint32_t idx = 0; - uint32_t tcData = 0; - for (idx = 0; idx <= tcLength; idx = idx + 4) { - tcData = *(ramBaseAddress + tcOffset + idx / 4); - if (idx == 0) { - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 2] = static_cast(tcData & 0xFF); - } - else if (tcLength - idx + 1 == 3) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - } - else if (tcLength - idx + 1 == 2) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - } - else if (tcLength - idx + 1 == 1) { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - } - else { - tcSegment[idx - 1] = static_cast((tcData >> 24) & 0xFF); - tcSegment[idx] = static_cast((tcData >> 16) & 0xFF); - tcSegment[idx + 1] = static_cast((tcData >> 8) & 0xFF); - tcSegment[idx + 2] = static_cast(tcData & 0xFF); - } - } + // Backend buffer is handled back to PDEC3 + *(registerBaseAddress + PDEC_BFREE_OFFSET) = 0; - // Backend buffer is handled back to PDEC3 - *(registerBaseAddress + PDEC_BFREE_OFFSET) = 0; - - return RETURN_OK; + return RETURN_OK; } void PdecHandler::printTC(uint32_t tcLength) { - std::stringstream tcSegmentStream; - tcSegmentStream << "TC segment data: 0x"; - for (uint32_t idx = 0; idx < tcLength; idx++) { - tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex - << static_cast(tcSegment[idx]); - } - sif::info << tcSegmentStream.str() << std::endl; + std::stringstream tcSegmentStream; + tcSegmentStream << "TC segment data: 0x"; + for (uint32_t idx = 0; idx < tcLength; idx++) { + tcSegmentStream << std::setfill('0') << std::setw(2) << std::hex + << static_cast(tcSegment[idx]); + } + sif::info << tcSegmentStream.str() << std::endl; } uint8_t PdecHandler::calcMapAddrEntry(uint8_t moduleId) { - uint8_t lutEntry = 0; - uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); - lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; - return lutEntry; + uint8_t lutEntry = 0; + uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); + lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; + return lutEntry; } uint8_t PdecHandler::getOddParity(uint8_t number) { - uint8_t parityBit = 0; - uint8_t countBits = 0; - for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { - countBits += (number >> idx) & 0x1; - } - parityBit = ~(countBits & 0x1) & 0x1; - return parityBit; + uint8_t parityBit = 0; + uint8_t countBits = 0; + for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { + countBits += (number >> idx) & 0x1; + } + parityBit = ~(countBits & 0x1) & 0x1; + return parityBit; } -uint32_t PdecHandler::getClcw() { - return *(registerBaseAddress + PDEC_CLCW_OFFSET); -} +uint32_t PdecHandler::getClcw() { return *(registerBaseAddress + PDEC_CLCW_OFFSET); } -uint32_t PdecHandler::getPdecMon() { - return *(registerBaseAddress + PDEC_MON_OFFSET); -} +uint32_t PdecHandler::getPdecMon() { return *(registerBaseAddress + PDEC_MON_OFFSET); } void PdecHandler::printClcw() { - uint32_t clcw = getClcw(); - uint8_t type = static_cast((clcw >> 31) & 0x1); - uint8_t versionNo = static_cast((clcw >> 29) & 0x3); - uint8_t status = static_cast((clcw >> 26) & 0x7); - uint8_t cop = static_cast((clcw >> 24) & 0x3); - uint8_t vcId = static_cast((clcw >> 18) & 0x3F); - uint8_t noRf = static_cast((clcw >> 15) & 0x1); - uint8_t noBitLock = static_cast((clcw >> 14) & 0x1); - uint8_t lockoutFlag = static_cast((clcw >> 13) & 0x1); - uint8_t waitFlag = static_cast((clcw >> 12) & 0x1); - uint8_t retransmitFlag = static_cast((clcw >> 11) & 0x1); - uint8_t farmBcnt = static_cast((clcw >> 9) & 0x3); - // Expected frame sequence number in te next AD frame - uint8_t repValue = static_cast(clcw & 0xFF); - sif::info << std::setw(30) << std::left << "CLCW type: " << std::hex - << "0x" << static_cast(type) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW version no: " << std::hex - << "0x" << static_cast(versionNo) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW status: " << std::hex - << "0x" << static_cast(status) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW COP: " << std::hex - << "0x" << static_cast(cop) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW virtual channel ID: " << std::hex - << "0x" << static_cast(vcId) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW no RF: " << std::hex - << "0x" << static_cast(noRf) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW no bit lock: " << std::hex - << "0x" << static_cast(noBitLock) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW lockout flag: " << std::hex - << "0x" << static_cast(lockoutFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW wait flag: " << std::hex - << "0x" << static_cast(waitFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW retransmit flag: " << std::hex - << "0x" << static_cast(retransmitFlag) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW FARM B count: " << std::hex - << "0x" << static_cast(farmBcnt) << std::endl; - sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex - << "0x" << static_cast(repValue) << std::endl; + uint32_t clcw = getClcw(); + uint8_t type = static_cast((clcw >> 31) & 0x1); + uint8_t versionNo = static_cast((clcw >> 29) & 0x3); + uint8_t status = static_cast((clcw >> 26) & 0x7); + uint8_t cop = static_cast((clcw >> 24) & 0x3); + uint8_t vcId = static_cast((clcw >> 18) & 0x3F); + uint8_t noRf = static_cast((clcw >> 15) & 0x1); + uint8_t noBitLock = static_cast((clcw >> 14) & 0x1); + uint8_t lockoutFlag = static_cast((clcw >> 13) & 0x1); + uint8_t waitFlag = static_cast((clcw >> 12) & 0x1); + uint8_t retransmitFlag = static_cast((clcw >> 11) & 0x1); + uint8_t farmBcnt = static_cast((clcw >> 9) & 0x3); + // Expected frame sequence number in te next AD frame + uint8_t repValue = static_cast(clcw & 0xFF); + sif::info << std::setw(30) << std::left << "CLCW type: " << std::hex << "0x" + << static_cast(type) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW version no: " << std::hex << "0x" + << static_cast(versionNo) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW status: " << std::hex << "0x" + << static_cast(status) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW COP: " << std::hex << "0x" + << static_cast(cop) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW virtual channel ID: " << std::hex << "0x" + << static_cast(vcId) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no RF: " << std::hex << "0x" + << static_cast(noRf) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW no bit lock: " << std::hex << "0x" + << static_cast(noBitLock) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW lockout flag: " << std::hex << "0x" + << static_cast(lockoutFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW wait flag: " << std::hex << "0x" + << static_cast(waitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW retransmit flag: " << std::hex << "0x" + << static_cast(retransmitFlag) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW FARM B count: " << std::hex << "0x" + << static_cast(farmBcnt) << std::endl; + sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex << "0x" + << static_cast(repValue) << std::endl; } void PdecHandler::printPdecMon() { - uint32_t pdecMon = getPdecMon(); - uint32_t tc0ChannelStatus = (pdecMon & TC0_STATUS_MASK) >> TC0_STATUS_POS; - uint32_t tc1ChannelStatus = (pdecMon & TC1_STATUS_MASK) >> TC1_STATUS_POS; - uint32_t tc2ChannelStatus = (pdecMon & TC2_STATUS_MASK) >> TC2_STATUS_POS; - uint32_t tc3ChannelStatus = (pdecMon & TC3_STATUS_MASK) >> TC3_STATUS_POS; - uint32_t tc4ChannelStatus = (pdecMon & TC4_STATUS_MASK) >> TC4_STATUS_POS; - uint32_t tc5ChannelStatus = (pdecMon & TC5_STATUS_MASK) >> TC5_STATUS_POS; - uint32_t lock = (pdecMon & LOCK_MASK) >> LOCK_POS; - sif::info << std::setw(30) << std::left << "TC0 status: " << getMonStatusString(tc0ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC1 status: " << getMonStatusString(tc1ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC2 status: " << getMonStatusString(tc2ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC3 status: " << getMonStatusString(tc3ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC4 status: " << getMonStatusString(tc4ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "TC5 status: " << getMonStatusString(tc5ChannelStatus) << std::endl; - sif::info << std::setw(30) << std::left << "Start sequence lock: " << lock << std::endl; + uint32_t pdecMon = getPdecMon(); + uint32_t tc0ChannelStatus = (pdecMon & TC0_STATUS_MASK) >> TC0_STATUS_POS; + uint32_t tc1ChannelStatus = (pdecMon & TC1_STATUS_MASK) >> TC1_STATUS_POS; + uint32_t tc2ChannelStatus = (pdecMon & TC2_STATUS_MASK) >> TC2_STATUS_POS; + uint32_t tc3ChannelStatus = (pdecMon & TC3_STATUS_MASK) >> TC3_STATUS_POS; + uint32_t tc4ChannelStatus = (pdecMon & TC4_STATUS_MASK) >> TC4_STATUS_POS; + uint32_t tc5ChannelStatus = (pdecMon & TC5_STATUS_MASK) >> TC5_STATUS_POS; + uint32_t lock = (pdecMon & LOCK_MASK) >> LOCK_POS; + sif::info << std::setw(30) << std::left << "TC0 status: " << getMonStatusString(tc0ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC1 status: " << getMonStatusString(tc1ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC2 status: " << getMonStatusString(tc2ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC3 status: " << getMonStatusString(tc3ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC4 status: " << getMonStatusString(tc4ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "TC5 status: " << getMonStatusString(tc5ChannelStatus) + << std::endl; + sif::info << std::setw(30) << std::left << "Start sequence lock: " << lock << std::endl; } std::string PdecHandler::getMonStatusString(uint32_t status) { - switch(status) { - case TC_CHANNEL_INACTIVE: - return std::string("inactive"); - case TC_CHANNEL_ACTIVE: - return std::string("active"); - case TC_CHANNEL_TIMEDOUT: - return std::string("timed out"); - default: - sif::warning << "PdecHandler::getMonStatusString: Invalid status" << std::endl; - return std::string(); - break; - } -} - - -ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - switch(actionId) { - case PRINT_CLCW: - printClcw(); - return EXECUTION_FINISHED; - case PRINT_PDEC_MON: - printPdecMon(); - return EXECUTION_FINISHED; + switch (status) { + case TC_CHANNEL_INACTIVE: + return std::string("inactive"); + case TC_CHANNEL_ACTIVE: + return std::string("active"); + case TC_CHANNEL_TIMEDOUT: + return std::string("timed out"); default: - return COMMAND_NOT_IMPLEMENTED; - } + sif::warning << "PdecHandler::getMonStatusString: Invalid status" << std::endl; + return std::string(); + break; + } +} + +ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + switch (actionId) { + case PRINT_CLCW: + printClcw(); + return EXECUTION_FINISHED; + case PRINT_PDEC_MON: + printPdecMon(); + return EXECUTION_FINISHED; + default: + return COMMAND_NOT_IMPLEMENTED; + } } diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 8c8e8d9b..2125800f 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -3,15 +3,15 @@ #include "OBSWConfig.h" #include "PdecConfig.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" -#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" /** * @brief This class controls the PDEC IP Core implemented in the programmable logic of the @@ -35,386 +35,381 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF, public HasActionsIF { + public: + /** + * @brief Constructor + * @param objectId Object ID of PDEC handler system object + * @param tcDestinationId Object ID of object responsible for processing TCs. + * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. + * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. + * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space + * @param uioregsiters String of uio device file same mapped to the PDEC register space + */ + PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, + gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, + std::string uioRegisters); -public: - /** - * @brief Constructor - * @param objectId Object ID of PDEC handler system object - * @param tcDestinationId Object ID of object responsible for processing TCs. - * @param gpioComIF Pointer to GPIO interace responsible for driving GPIOs. - * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. - * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space - * @param uioregsiters String of uio device file same mapped to the PDEC register space - */ - PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, - gpioId_t pdecReset, std::string uioConfigMemory, std::string uioRamMemory, - std::string uioRegisters); + virtual ~PdecHandler(); - virtual ~PdecHandler(); + ReturnValue_t performOperation(uint8_t operationCode = 0); - ReturnValue_t performOperation(uint8_t operationCode = 0); + ReturnValue_t initialize() override; - ReturnValue_t initialize() override; + MessageQueueId_t getCommandQueue() const; - MessageQueueId_t getCommandQueue() const; + 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; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; + //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame + //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) + //! P2: When frame declared illegal this parameter this parameter gives information about the + //! reason (IReason field of the PDEC_FAR register) + static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); + //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup + static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); + //! [EXPORT] : [COMMENT] Carrier lock detected + static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); + //! [EXPORT] : [COMMENT] Bit lock detected (data valid) + static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); - //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame - //! P1: The frame analysis information (FrameAna field of PDEC_FAR register) - //! P2: When frame declared illegal this parameter this parameter gives information about the reason (IReason field of the PDEC_FAR register) - static const Event INVALID_TC_FRAME = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup - static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH); - //! [EXPORT] : [COMMENT] Carrier lock detected - static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO); - //! [EXPORT] : [COMMENT] Bit lock detected (data valid) - static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; -private: + static const ReturnValue_t ABANDONED_CLTU = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t FRAME_DIRTY = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t AD_DISCARDED_LOCKOUT = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); - static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER; + //! [EXPORT] : [COMMENT] Received action message with unknown action id + static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); - static const ReturnValue_t ABANDONED_CLTU = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t FRAME_DIRTY = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t FRAME_ILLEGAL_ONE_REASON = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t FRAME_ILLEGAL_MULTIPLE_REASONS = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t AD_DISCARDED_LOCKOUT = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); + //! Error in version number and reserved A and B fields + static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); + //! Illegal combination of bypass and control command flag + static const ReturnValue_t ILLEGAL_COMBINATION = MAKE_RETURN_CODE(0xA8); + //! Spacecraft identifier did not match + static const ReturnValue_t INVALID_SC_ID = MAKE_RETURN_CODE(0xA9); + //! VC identifier bits 0 to 4 did not match + static const ReturnValue_t INVALID_VC_ID_MSB = MAKE_RETURN_CODE(0xAA); + //! VC identifier bit 5 did not match + static const ReturnValue_t INVALID_VC_ID_LSB = MAKE_RETURN_CODE(0xAB); + //! N(S) of BC or BD frame not set to all zeros + static const ReturnValue_t NS_NOT_ZERO = MAKE_RETURN_CODE(0xAC); + //! Invalid BC control command + static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Received action message with unknown action id - static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0); + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6); - //! Error in version number and reserved A and B fields - static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7); - //! Illegal combination of bypass and control command flag - static const ReturnValue_t ILLEGAL_COMBINATION = MAKE_RETURN_CODE(0xA8); - //! Spacecraft identifier did not match - static const ReturnValue_t INVALID_SC_ID = MAKE_RETURN_CODE(0xA9); - //! VC identifier bits 0 to 4 did not match - static const ReturnValue_t INVALID_VC_ID_MSB = MAKE_RETURN_CODE(0xAA); - //! VC identifier bit 5 did not match - static const ReturnValue_t INVALID_VC_ID_LSB = MAKE_RETURN_CODE(0xAB); - //! N(S) of BC or BD frame not set to all zeros - static const ReturnValue_t NS_NOT_ZERO = MAKE_RETURN_CODE(0xAC); - //! Invalid BC control command - static const ReturnValue_t INVALID_BC_CC = MAKE_RETURN_CODE(0xAE); + // Action IDs + static const ActionId_t PRINT_CLCW = 0; + // Print PDEC monitor register + static const ActionId_t PRINT_PDEC_MON = 1; - static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; + static const uint8_t STAT_POSITION = 31; + static const uint8_t FRAME_ANA_POSITION = 28; + static const uint8_t IREASON_POSITION = 25; - // Action IDs - static const ActionId_t PRINT_CLCW = 0; - // Print PDEC monitor register - static const ActionId_t PRINT_PDEC_MON = 1; + static const uint8_t NEW_FAR_RECEIVED = 0; - static const uint8_t STAT_POSITION = 31; - static const uint8_t FRAME_ANA_POSITION = 28; - static const uint8_t IREASON_POSITION = 25; + static const uint32_t FRAME_ANA_MASK = 0x70000000; + static const uint32_t IREASON_MASK = 0x0E000000; - static const uint8_t NEW_FAR_RECEIVED = 0; + static const uint32_t TC_CHANNEL_INACTIVE = 0x0; + static const uint32_t TC_CHANNEL_ACTIVE = 0x1; + static const uint32_t TC_CHANNEL_TIMEDOUT = 0x2; - static const uint32_t FRAME_ANA_MASK = 0x70000000; - static const uint32_t IREASON_MASK = 0x0E000000; + static const uint32_t TC0_STATUS_MASK = 0x3; + static const uint32_t TC1_STATUS_MASK = 0xC; + static const uint32_t TC2_STATUS_MASK = 0x300; + static const uint32_t TC3_STATUS_MASK = 0xC00; + static const uint32_t TC4_STATUS_MASK = 0x30000; + static const uint32_t TC5_STATUS_MASK = 0xc00000; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_MASK = 0xc00000; - static const uint32_t TC_CHANNEL_INACTIVE = 0x0; - static const uint32_t TC_CHANNEL_ACTIVE = 0x1; - static const uint32_t TC_CHANNEL_TIMEDOUT = 0x2; + static const uint32_t TC0_STATUS_POS = 0; + static const uint32_t TC1_STATUS_POS = 2; + static const uint32_t TC2_STATUS_POS = 4; + static const uint32_t TC3_STATUS_POS = 6; + static const uint32_t TC4_STATUS_POS = 8; + static const uint32_t TC5_STATUS_POS = 10; + // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) + static const uint32_t LOCK_POS = 12; - static const uint32_t TC0_STATUS_MASK = 0x3; - static const uint32_t TC1_STATUS_MASK = 0xC; - static const uint32_t TC2_STATUS_MASK = 0x300; - static const uint32_t TC3_STATUS_MASK = 0xC00; - static const uint32_t TC4_STATUS_MASK = 0x30000; - static const uint32_t TC5_STATUS_MASK = 0xc00000; - // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) - static const uint32_t LOCK_MASK = 0xc00000; - - static const uint32_t TC0_STATUS_POS = 0; - static const uint32_t TC1_STATUS_POS = 2; - static const uint32_t TC2_STATUS_POS = 4; - static const uint32_t TC3_STATUS_POS = 6; - static const uint32_t TC4_STATUS_POS = 8; - static const uint32_t TC5_STATUS_POS = 10; - // Lock register set to 1 when start sequence has been found (CLTU is beeing processed) - static const uint32_t LOCK_POS = 12; - - /** - * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 - * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 - */ - static const uint32_t PDEC_FAR_OFFSET = 0xA10; - static const uint32_t PDEC_CLCW_OFFSET = 0xA12; - static const uint32_t PDEC_BFREE_OFFSET = 0xA24; - static const uint32_t PDEC_BPTR_OFFSET = 0xA25; - static const uint32_t PDEC_SLEN_OFFSET = 0xA26; - static const uint32_t PDEC_MON_OFFSET = 0xA27; + /** + * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 + * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 + */ + static const uint32_t PDEC_FAR_OFFSET = 0xA10; + static const uint32_t PDEC_CLCW_OFFSET = 0xA12; + static const uint32_t PDEC_BFREE_OFFSET = 0xA24; + static const uint32_t PDEC_BPTR_OFFSET = 0xA25; + static const uint32_t PDEC_SLEN_OFFSET = 0xA26; + static const uint32_t PDEC_MON_OFFSET = 0xA27; #if BOARD_TE0720 == 1 - static const int CONFIG_MEMORY_MAP_SIZE = 0x400; - static const int RAM_MAP_SIZE = 0x4000; - static const int REGISTER_MAP_SIZE = 0x10000; + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; + static const int REGISTER_MAP_SIZE = 0x10000; #else - static const int CONFIG_MEMORY_MAP_SIZE = 0x400; - static const int RAM_MAP_SIZE = 0x4000; - static const int REGISTER_MAP_SIZE = 0x4000; + static const int CONFIG_MEMORY_MAP_SIZE = 0x400; + static const int RAM_MAP_SIZE = 0x4000; + static const int REGISTER_MAP_SIZE = 0x4000; #endif /* BOARD_TE0720 == 1 */ - // 0x200 / 4 = 0x80 - static const uint32_t FRAME_HEADER_OFFSET = 0x80; + // 0x200 / 4 = 0x80 + static const uint32_t FRAME_HEADER_OFFSET = 0x80; - static const size_t MAX_TC_SEGMENT_SIZE = 1017; - static const uint8_t MAP_ID_MASK = 0x3F; + static const size_t MAX_TC_SEGMENT_SIZE = 1017; + static const uint8_t MAP_ID_MASK = 0x3F; #if BOARD_TE0720 == 1 - static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x32000000; #else - static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; + static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; #endif - static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; - static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; + static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; + static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; - static const uint8_t MAX_MAP_ADDR = 63; - // Writing this to the map address in the look up table will invalidate a MAP ID. - static const uint8_t NO_DESTINATION = 0; - static const uint8_t VALID_POSITION = 6; - static const uint8_t PARITY_POSITION = 7; + static const uint8_t MAX_MAP_ADDR = 63; + // Writing this to the map address in the look up table will invalidate a MAP ID. + static const uint8_t NO_DESTINATION = 0; + static const uint8_t VALID_POSITION = 6; + static const uint8_t PARITY_POSITION = 7; - // Expected value stored in FAR register after reset - static const uint32_t FAR_RESET = 0x7FE0; + // Expected value stored in FAR register after reset + static const uint32_t FAR_RESET = 0x7FE0; - static const uint32_t TC_SEGMENT_LEN = 1017; + static const uint32_t TC_SEGMENT_LEN = 1017; - static const uint32_t NO_RF_MASK = 0x8000; - static const uint32_t NO_BITLOCK_MASK = 0x4000; + static const uint32_t NO_RF_MASK = 0x8000; + static const uint32_t NO_BITLOCK_MASK = 0x4000; - /** - * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in - * the PDEC memory. - */ - static const uint8_t PM_BUFFER = 7; + /** + * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in + * the PDEC memory. + */ + static const uint8_t PM_BUFFER = 7; - // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be - // discarded - static const uint8_t MAP_CLK_FREQ = 2; + // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be + // discarded + static const uint8_t MAP_CLK_FREQ = 2; - enum class FrameAna_t: uint8_t { - ABANDONED_CLTU, - FRAME_DIRTY, - FRAME_ILLEGAL, - FRAME_ILLEGAL_MULTI_REASON, - AD_DISCARDED_LOCKOUT, - AD_DISCARDED_WAIT, - AD_DISCARDED_NS_VR, - FRAME_ACCEPTED - }; + enum class FrameAna_t : uint8_t { + ABANDONED_CLTU, + FRAME_DIRTY, + FRAME_ILLEGAL, + FRAME_ILLEGAL_MULTI_REASON, + AD_DISCARDED_LOCKOUT, + AD_DISCARDED_WAIT, + AD_DISCARDED_NS_VR, + FRAME_ACCEPTED + }; - enum class IReason_t: uint8_t { - NO_REPORT, - ERROR_VERSION_NUMBER, - ILLEGAL_COMBINATION, - INVALID_SC_ID, - INVALID_VC_ID_LSB, - INVALID_VC_ID_MSB, - NS_NOT_ZERO, - INCORRECT_BC_CC - }; + enum class IReason_t : uint8_t { + NO_REPORT, + ERROR_VERSION_NUMBER, + ILLEGAL_COMBINATION, + INVALID_SC_ID, + INVALID_VC_ID_LSB, + INVALID_VC_ID_MSB, + NS_NOT_ZERO, + INCORRECT_BC_CC + }; - enum class State: uint8_t { - INIT, - RUNNING, - WAIT_FOR_RECOVERY - }; + enum class State : uint8_t { INIT, RUNNING, WAIT_FOR_RECOVERY }; - /** - * @brief Reads and handles messages stored in the commandQueue - */ - void readCommandQueue(void); + /** + * @brief Reads and handles messages stored in the commandQueue + */ + void readCommandQueue(void); - /** - * @brief Opens UIO device assigned to AXI to AHB converter giving access to the PDEC - * registers. The register base address will be mapped into the virtual address space. - */ - ReturnValue_t getRegisterAddress(); + /** + * @brief Opens UIO device assigned to AXI to AHB converter giving access to the PDEC + * registers. The register base address will be mapped into the virtual address space. + */ + ReturnValue_t getRegisterAddress(); - /** - * @brief Opens UIO device assigned to the base address of the PDEC memory space and maps the - * physical address into the virtual address space. - */ - ReturnValue_t getConfigMemoryBaseAddress(); + /** + * @brief Opens UIO device assigned to the base address of the PDEC memory space and maps the + * physical address into the virtual address space. + */ + ReturnValue_t getConfigMemoryBaseAddress(); - /** - * @brief Opens UIO device assigned to the RAM section of the PDEC IP core memory map. - * - * @details A received TC segment will be written to this memory area. - */ - ReturnValue_t getRamBaseAddress(); + /** + * @brief Opens UIO device assigned to the RAM section of the PDEC IP core memory map. + * + * @details A received TC segment will be written to this memory area. + */ + ReturnValue_t getRamBaseAddress(); - /** - * @brief This functions writes the configuration parameters to the configuration - * section of the PDEC. - */ - void writePdecConfig(); + /** + * @brief This functions writes the configuration parameters to the configuration + * section of the PDEC. + */ + void writePdecConfig(); - /** - * @brief Reading the FAR resets the set stat flag which signals a new TC. Without clearing - * this flag no new TC will be excepted. After start up the flag is set and needs - * to be reset. - * Stat flag 0 - new TC received - * Stat flag 1 - old TC (ready to receive next TC) - */ - ReturnValue_t resetFarStatFlag(); + /** + * @brief Reading the FAR resets the set stat flag which signals a new TC. Without clearing + * this flag no new TC will be excepted. After start up the flag is set and needs + * to be reset. + * Stat flag 0 - new TC received + * Stat flag 1 - old TC (ready to receive next TC) + */ + ReturnValue_t resetFarStatFlag(); - /** - * @brief Releases the PDEC from reset state. PDEC will start with loading the written - * configuration parameters. - */ - ReturnValue_t releasePdec(); + /** + * @brief Releases the PDEC from reset state. PDEC will start with loading the written + * configuration parameters. + */ + ReturnValue_t releasePdec(); - /** - * @brief Reads the FAR register and checks if a new TC has been received. - */ - bool newTcReceived(); + /** + * @brief Reads the FAR register and checks if a new TC has been received. + */ + bool newTcReceived(); - /** - * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate - * event. - */ - void checkLocks(); + /** + * @brief Checks if carrier lock or bit lock has been detected and triggers appropriate + * event. + */ + void checkLocks(); - /** - * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. - * - * @return True if frame valid, otherwise false. - */ - bool checkFrameAna(uint32_t pdecFar); + /** + * @brief Analyzes the FramAna field (frame analysis data) of a FAR report. + * + * @return True if frame valid, otherwise false. + */ + bool checkFrameAna(uint32_t pdecFar); - /** - * @brief This function handles the IReason field of the frame analysis report. - * - * @details In case frame as been declared illegal for multiple reasons, the reason with the - * lowest value will be shown. - */ - void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); + /** + * @brief This function handles the IReason field of the frame analysis report. + * + * @details In case frame as been declared illegal for multiple reasons, the reason with the + * lowest value will be shown. + */ + void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); - /** - * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the - * new TC segment, extracts the PUS packet and forwards the data to the object - * responsible for processing the TC. - */ - void handleNewTc(); + /** + * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the + * new TC segment, extracts the PUS packet and forwards the data to the object + * responsible for processing the TC. + */ + void handleNewTc(); - /** - * @brief Function reads the last received TC segment from the PDEC memory and copies - * the data to the tcSegement array. - * - * @param tcLength The length of the received TC. - * - */ - ReturnValue_t readTc(uint32_t& tcLength); + /** + * @brief Function reads the last received TC segment from the PDEC memory and copies + * the data to the tcSegement array. + * + * @param tcLength The length of the received TC. + * + */ + ReturnValue_t readTc(uint32_t& tcLength); - /** - * @brief Prints the tc segment data - */ - void printTC(uint32_t tcLength); + /** + * @brief Prints the tc segment data + */ + void printTC(uint32_t tcLength); - /** - * @brief This function calculates the entry for the configuration of the MAP ID routing. - * - * @param mapAddr The MAP ID to configure - * @param moduleId The destination module where all TCs with the map id mapAddr will be routed - * to. - * - * @details The PDEC has different modules where the TCs can be routed to. A lookup table is - * used which links the MAP ID field to the destination module. The entry for this - * lookup table is created by this function and must be stored in the configuration - * memory region of the PDEC. The entry has a specific format - */ - uint8_t calcMapAddrEntry(uint8_t moduleId); + /** + * @brief This function calculates the entry for the configuration of the MAP ID routing. + * + * @param mapAddr The MAP ID to configure + * @param moduleId The destination module where all TCs with the map id mapAddr will be routed + * to. + * + * @details The PDEC has different modules where the TCs can be routed to. A lookup table is + * used which links the MAP ID field to the destination module. The entry for this + * lookup table is created by this function and must be stored in the configuration + * memory region of the PDEC. The entry has a specific format + */ + uint8_t calcMapAddrEntry(uint8_t moduleId); - /** - * @brief This functions calculates the odd parity of the bits in number. - * - * @param number The number from which to calculate the odd parity. - */ - uint8_t getOddParity(uint8_t number); + /** + * @brief This functions calculates the odd parity of the bits in number. + * + * @param number The number from which to calculate the odd parity. + */ + uint8_t getOddParity(uint8_t number); - /** - * brief Returns the 32-bit wide communication link control word (CLCW) - */ - uint32_t getClcw(); + /** + * brief Returns the 32-bit wide communication link control word (CLCW) + */ + uint32_t getClcw(); - /** - * @brief Returns the PDEC monitor register content - * - */ - uint32_t getPdecMon(); + /** + * @brief Returns the PDEC monitor register content + * + */ + uint32_t getPdecMon(); - /** - * @brief Reads and prints the CLCW. Can be useful for debugging. - */ - void printClcw(); + /** + * @brief Reads and prints the CLCW. Can be useful for debugging. + */ + void printClcw(); - /** - * @brief Prints monitor register information to debug console. - */ - void printPdecMon(); + /** + * @brief Prints monitor register information to debug console. + */ + void printPdecMon(); - std::string getMonStatusString(uint32_t status); + std::string getMonStatusString(uint32_t status); - object_id_t tcDestinationId; + object_id_t tcDestinationId; - AcceptsTelecommandsIF* tcDestination = nullptr; + AcceptsTelecommandsIF* tcDestination = nullptr; - LinuxLibgpioIF* gpioComIF = nullptr; + LinuxLibgpioIF* gpioComIF = nullptr; - /** - * Reset signal is required to hold PDEC in reset state until the configuration has been - * written to the appropriate memory space. - * Can also be used to reboot PDEC in case of erros. - */ - gpioId_t pdecReset = gpio::NO_GPIO; + /** + * Reset signal is required to hold PDEC in reset state until the configuration has been + * written to the appropriate memory space. + * Can also be used to reboot PDEC in case of erros. + */ + gpioId_t pdecReset = gpio::NO_GPIO; - // UIO device file giving access to the PDEC configuration memory section - std::string uioConfigMemory; + // UIO device file giving access to the PDEC configuration memory section + std::string uioConfigMemory; - // UIO device file giving access to the PDEC RAM section - std::string uioRamMemory; + // UIO device file giving access to the PDEC RAM section + std::string uioRamMemory; - // UIO device file giving access to the PDEC register space - std::string uioRegisters; + // UIO device file giving access to the PDEC register space + std::string uioRegisters; - ActionHelper actionHelper; + ActionHelper actionHelper; - StorageManagerIF* tcStore = nullptr; + StorageManagerIF* tcStore = nullptr; - MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; - State state = State::INIT; + State state = State::INIT; - /** - * Pointer pointing to base address of the PDEC memory space. - * This address is equivalent with the base address of the section named configuration area in - * the PDEC datasheet. - */ - uint32_t* memoryBaseAddress = nullptr; + /** + * Pointer pointing to base address of the PDEC memory space. + * This address is equivalent with the base address of the section named configuration area in + * the PDEC datasheet. + */ + uint32_t* memoryBaseAddress = nullptr; - uint32_t* ramBaseAddress = nullptr; + uint32_t* ramBaseAddress = nullptr; - // Pointer pointing to base address of register space - uint32_t* registerBaseAddress = nullptr; + // Pointer pointing to base address of register space + uint32_t* registerBaseAddress = nullptr; - uint32_t pdecFar = 0; + uint32_t pdecFar = 0; - uint8_t tcSegment[TC_SEGMENT_LEN]; + uint8_t tcSegment[TC_SEGMENT_LEN]; - // Used to check carrier and bit lock changes (default set to no rf and no bitlock) - uint32_t lastClcw = 0xC000; + // Used to check carrier and bit lock changes (default set to no rf and no bitlock) + uint32_t lastClcw = 0xC000; }; #endif /* LINUX_OBC_PDECHANDLER_H_ */ diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 63af5d33..237e66ab 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -1,72 +1,69 @@ -#include #include - #include -#include "fsfw/serviceinterface/ServiceInterface.h" +#include + #include "PtmeConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" -Ptme::Ptme(object_id_t objectId): SystemObject(objectId) { -} +Ptme::Ptme(object_id_t objectId) : SystemObject(objectId) {} -Ptme::~Ptme() { -} +Ptme::~Ptme() {} ReturnValue_t Ptme::initialize() { + int fd = open(PtmeConfig::UIO_DEVICE_FILE, O_RDWR); + if (fd < 1) { + sif::warning << "Ptme::initialize: Invalid UIO device file" << std::endl; + return RETURN_FAILED; + } - int fd = open(PtmeConfig::UIO_DEVICE_FILE, O_RDWR); - if (fd < 1) { - sif::warning << "Ptme::initialize: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } + /** + * Map uio device in virtual address space + * PROT_WRITE: Map uio device in writable only mode + */ + ptmeBaseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE, MAP_SHARED, fd, 0)); - /** - * Map uio device in virtual address space - * PROT_WRITE: Map uio device in writable only mode - */ - ptmeBaseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE, - MAP_SHARED, fd, 0)); + if (ptmeBaseAddress == MAP_FAILED) { + sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; + return RETURN_FAILED; + } - if (ptmeBaseAddress == MAP_FAILED) { - sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } + VcInterfaceMapIter iter; + for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { + iter->second->setRegisterAddress(ptmeBaseAddress); + } - VcInterfaceMapIter iter; - for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { - iter->second->setRegisterAddress(ptmeBaseAddress); - } - - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t * data, size_t size) { - ReturnValue_t result = RETURN_OK; - VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); - if (vcInterfaceMapIter == vcInterfaceMap.end()) { - sif::warning << "Ptme::writeToVc: No virtual channel interface found for the virtual " - "channel with id " << static_cast(vcId) << std::endl; - return UNKNOWN_VC_ID; - } - result = vcInterfaceMapIter->second->write(data, size); - return result; +ReturnValue_t Ptme::writeToVc(uint8_t vcId, const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; + VcInterfaceMapIter vcInterfaceMapIter = vcInterfaceMap.find(vcId); + if (vcInterfaceMapIter == vcInterfaceMap.end()) { + sif::warning << "Ptme::writeToVc: No virtual channel interface found for the virtual " + "channel with id " + << static_cast(vcId) << std::endl; + return UNKNOWN_VC_ID; + } + result = vcInterfaceMapIter->second->write(data, size); + return result; } void Ptme::addVcInterface(VcId_t vcId, VcInterfaceIF* vc) { + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; + return; + } - if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { - sif::warning << "Ptme::addVcInterface: Invalid virtual channel ID" << std::endl; - return; - } + if (vc == nullptr) { + sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl; + return; + } - if (vc == nullptr) { - sif::warning << "Ptme::addVcInterface: Invalid virtual channel interface" << std::endl; - return; - } - - auto status = vcInterfaceMap.emplace(vcId, vc); - if (status.second == false) { - sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to " - "virtual channel map" << std::endl; - return; - } + auto status = vcInterfaceMap.emplace(vcId, vc); + if (status.second == false) { + sif::warning << "Ptme::addVcInterface: Failed to add virtual channel interface to " + "virtual channel map" + << std::endl; + return; + } } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index 5364974f..d85885bc 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -1,91 +1,87 @@ #ifndef LINUX_OBC_PTME_H_ #define LINUX_OBC_PTME_H_ -#include "OBSWConfig.h" -#include "linux/obc/PtmeIF.h" -#include "linux/obc/VcInterfaceIF.h" #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include #include +#include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "linux/obc/PtmeIF.h" +#include "linux/obc/VcInterfaceIF.h" + /** * @brief This class handles the interfacing to the telemetry (PTME) IP core responsible for the - * encoding of telemetry packets according to the CCSDS standards CCSDS 131.0-B-3 (TM Synchro- - * nization and channel coding) and CCSDS 132.0-B-2 (TM Space Data Link Protocoll). - * The IP cores are implemented on the programmable logic and are accessible through the - * linux UIO driver. + * encoding of telemetry packets according to the CCSDS standards CCSDS 131.0-B-3 (TM + * Synchro- nization and channel coding) and CCSDS 132.0-B-2 (TM Space Data Link Protocoll). The IP + * cores are implemented on the programmable logic and are accessible through the linux UIO driver. */ -class Ptme : public PtmeIF, - public SystemObject, - public HasReturnvaluesIF { -public: +class Ptme : public PtmeIF, public SystemObject, public HasReturnvaluesIF { + public: + using VcId_t = uint8_t; - using VcId_t = uint8_t; + /** + * @brief Constructor + * + * @param objectId + */ + Ptme(object_id_t objectId); + virtual ~Ptme(); - /** - * @brief Constructor - * - * @param objectId - */ - Ptme(object_id_t objectId); - virtual ~Ptme(); + ReturnValue_t initialize() override; + ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override; - ReturnValue_t initialize() override; - ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) override; + /** + * @brief This function adds the reference to a virtual channel interface to the vcInterface + * map. + */ + void addVcInterface(VcId_t vcId, VcInterfaceIF* vc); - /** - * @brief This function adds the reference to a virtual channel interface to the vcInterface - * map. - */ - void addVcInterface(VcId_t vcId, VcInterfaceIF* vc); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PTME; -private: - - static const uint8_t INTERFACE_ID = CLASS_ID::PTME; - - static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0); #if BOARD_TE0720 == 1 - /** Size of mapped address space */ - static const int MAP_SIZE = 0x40000; + /** Size of mapped address space */ + static const int MAP_SIZE = 0x40000; #else - /** Size of mapped address space */ - static const int MAP_SIZE = 0x40000; + /** Size of mapped address space */ + static const int MAP_SIZE = 0x40000; #endif /* BOARD_TE0720 == 1 */ - /** - * Configuration bits: - * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 - * bit[2]: Set this bit to 1 to abort a transfered packet - * bit[3]: Signals to PTME the start of a new telemetry packet - */ - static const uint32_t PTME_CONFIG_START = 0x8; + /** + * Configuration bits: + * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 + * bit[2]: Set this bit to 1 to abort a transfered packet + * bit[3]: Signals to PTME the start of a new telemetry packet + */ + static const uint32_t PTME_CONFIG_START = 0x8; - /** - * Writing this word to the ptme base address signals to the PTME that a complete tm packet has - * been transferred. - */ - static const uint32_t PTME_CONFIG_END = 0x0; + /** + * Writing this word to the ptme base address signals to the PTME that a complete tm packet has + * been transferred. + */ + static const uint32_t PTME_CONFIG_END = 0x0; - /** - * Writing to this offset within the PTME memory space will insert data for encoding to the - * PTME IP core. - * The address offset is 0x400 (= 4 * 256) - */ - static const int PTME_DATA_REG_OFFSET = 256; + /** + * Writing to this offset within the PTME memory space will insert data for encoding to the + * PTME IP core. + * The address offset is 0x400 (= 4 * 256) + */ + static const int PTME_DATA_REG_OFFSET = 256; - /** The file descriptor of the UIO driver */ - int fd = 0; + /** The file descriptor of the UIO driver */ + int fd = 0; - uint32_t* ptmeBaseAddress = nullptr; + uint32_t* ptmeBaseAddress = nullptr; - using VcInterfaceMap = std::unordered_map; - using VcInterfaceMapIter = VcInterfaceMap::iterator; + using VcInterfaceMap = std::unordered_map; + using VcInterfaceMapIter = VcInterfaceMap::iterator; - VcInterfaceMap vcInterfaceMap; + VcInterfaceMap vcInterfaceMap; }; #endif /* LINUX_OBC_PTME_H_ */ diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index 814dfeda..b5b722ac 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -1,9 +1,10 @@ #ifndef LINUX_OBC_PTMECONFIG_H_ #define LINUX_OBC_PTMECONFIG_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include + #include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * @brief PTME specific configuration parameters derived from FPGA design and device tree. @@ -11,20 +12,20 @@ * @author J. Meier */ namespace PtmeConfig { - /** - * Offset of virtual channels mapped into address space - * 0x10000 = (0x4000 * 4) - */ - static const uint32_t VC0_OFFSETT = 0; - static const uint32_t VC1_OFFSETT = 0x4000; - static const uint32_t VC2_OFFSETT = 0x8000; - static const uint32_t VC3_OFFSETT = 0xC000; +/** + * Offset of virtual channels mapped into address space + * 0x10000 = (0x4000 * 4) + */ +static const uint32_t VC0_OFFSETT = 0; +static const uint32_t VC1_OFFSETT = 0x4000; +static const uint32_t VC2_OFFSETT = 0x8000; +static const uint32_t VC3_OFFSETT = 0xC000; #if BOARD_TE0720 == 0 - static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #else - static const char UIO_DEVICE_FILE[] = "/dev/uio1"; +static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #endif -}; +}; // namespace PtmeConfig #endif /* LINUX_OBC_PTMECONFIG_H_ */ diff --git a/linux/obc/PtmeIF.h b/linux/obc/PtmeIF.h index 53d9498b..7108df05 100644 --- a/linux/obc/PtmeIF.h +++ b/linux/obc/PtmeIF.h @@ -3,7 +3,6 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" - /** * @brief Interface class for managing the PTME IP Core implemented in the programmable logic. * @@ -12,17 +11,17 @@ * @author J. Meier */ class PtmeIF { -public: - virtual ~PtmeIF(){}; + public: + virtual ~PtmeIF(){}; - /** - * @brief Implements to function to write to a specific virtual channel. - * - * @param vcId Virtual channel to write to - * @param data Pointer to buffer holding the data to write - * @param size Number of bytes to write - */ - virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0; + /** + * @brief Implements to function to write to a specific virtual channel. + * + * @param vcId Virtual channel to write to + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t writeToVc(uint8_t vcId, const uint8_t* data, size_t size) = 0; }; #endif /* LINUX_OBC_PTMEIF_H_ */ diff --git a/linux/obc/PtmeRateSetter.cpp b/linux/obc/PtmeRateSetter.cpp index 92886623..b5a6ee1c 100644 --- a/linux/obc/PtmeRateSetter.cpp +++ b/linux/obc/PtmeRateSetter.cpp @@ -1,27 +1,25 @@ #include "PtmeRateSetter.h" + #include "fsfw/serviceinterface/ServiceInterface.h" -PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) : - bitrateSel(bitrateSel), gpioif(gpioif) { -} +PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) + : bitrateSel(bitrateSel), gpioif(gpioif) {} -PtmeRateSetter::~PtmeRateSetter() { -} +PtmeRateSetter::~PtmeRateSetter() {} ReturnValue_t PtmeRateSetter::setRate(BitRates rate) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - switch(rate) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + switch (rate) { case RATE_2000KHZ: - result = gpioif->pullHigh(bitrateSel); - break; + result = gpioif->pullHigh(bitrateSel); + break; case RATE_400KHZ: - result = gpioif->pullLow(bitrateSel); - break; + result = gpioif->pullLow(bitrateSel); + break; default: - sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; - result = HasReturnvaluesIF::RETURN_FAILED; - break; - } - return result; + sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; + result = HasReturnvaluesIF::RETURN_FAILED; + break; + } + return result; } - diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h index ece78e91..14dfec4b 100644 --- a/linux/obc/PtmeRateSetter.h +++ b/linux/obc/PtmeRateSetter.h @@ -2,9 +2,9 @@ #define LINUX_OBC_PTMERATESETTER_H_ #include "TxRateSetterIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" -#include "fsfw_hal/common/gpio/GpioIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw_hal/common/gpio/GpioIF.h" +#include "fsfw_hal/common/gpio/gpioDefinitions.h" /** * @brief Class to set the downlink bit rate by using the cadu_rate_switcher implemented in @@ -15,26 +15,24 @@ * * @author J. Meier */ -class PtmeRateSetter: public TxRateSetterIF { -public: +class PtmeRateSetter : public TxRateSetterIF { + public: + /** + * @brief Constructor + * + * @param bitrateSel GPIO ID of the GPIO connected to the bitrate_sel input of the + * cadu_rate_switcher. + * @param gpioif GPIO interface to drive the bitrateSel GPIO + */ + PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif); + virtual ~PtmeRateSetter(); - /** - * @brief Constructor - * - * @param bitrateSel GPIO ID of the GPIO connected to the bitrate_sel input of the - * cadu_rate_switcher. - * @param gpioif GPIO interface to drive the bitrateSel GPIO - */ - PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif); - virtual ~PtmeRateSetter(); + virtual ReturnValue_t setRate(BitRates rate); - virtual ReturnValue_t setRate(BitRates rate); + private: + gpioId_t bitrateSel = gpio::NO_GPIO; -private: - - gpioId_t bitrateSel = gpio::NO_GPIO; - - GpioIF* gpioif = nullptr; + GpioIF* gpioif = nullptr; }; #endif /* LINUX_OBC_PTMERATESETTER_H_ */ diff --git a/linux/obc/TxRateSetterIF.h b/linux/obc/TxRateSetterIF.h index c07106e4..1eaded33 100644 --- a/linux/obc/TxRateSetterIF.h +++ b/linux/obc/TxRateSetterIF.h @@ -3,10 +3,7 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -enum BitRates : uint32_t { - RATE_2000KHZ, - RATE_400KHZ -}; +enum BitRates : uint32_t { RATE_2000KHZ, RATE_400KHZ }; /** * @brief Abstract class for objects implementing the functionality to switch the @@ -15,11 +12,11 @@ enum BitRates : uint32_t { * @author J. Meier */ class TxRateSetterIF { -public: - TxRateSetterIF() {}; - virtual ~TxRateSetterIF() {}; + public: + TxRateSetterIF(){}; + virtual ~TxRateSetterIF(){}; - virtual ReturnValue_t setRate(BitRates bitRate) = 0; + virtual ReturnValue_t setRate(BitRates bitRate) = 0; }; #endif /* LINUX_OBC_TXRATESETTERIF_H_ */ diff --git a/linux/obc/VcInterfaceIF.h b/linux/obc/VcInterfaceIF.h index 28b8d1f1..0aa95691 100644 --- a/linux/obc/VcInterfaceIF.h +++ b/linux/obc/VcInterfaceIF.h @@ -2,6 +2,7 @@ #define LINUX_OBC_VCINTERFACEIF_H_ #include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" /** @@ -11,19 +12,19 @@ * @author J. Meier */ class VcInterfaceIF { -public: - virtual ~VcInterfaceIF(){}; + public: + virtual ~VcInterfaceIF(){}; - /** - * @brief Implememts the functionality to write data in the virtual channel of the PTME IP - * Core. - * - * @param data Pointer to buffer holding the data to write - * @param size Number of bytes to write - */ - virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; + /** + * @brief Implememts the functionality to write data in the virtual channel of the PTME IP + * Core. + * + * @param data Pointer to buffer holding the data to write + * @param size Number of bytes to write + */ + virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; - virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; + virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; }; #endif /* LINUX_OBC_VCINTERFACEIF_H_ */ diff --git a/linux/utility/utility.cpp b/linux/utility/utility.cpp index 1d6ec5c0..cd0d47ef 100644 --- a/linux/utility/utility.cpp +++ b/linux/utility/utility.cpp @@ -1,13 +1,14 @@ -#include "OBSWConfig.h" -#include "FSFWConfig.h" #include "utility.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include +#include "FSFWConfig.h" +#include "OBSWConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + void utility::handleSystemError(int retcode, std::string function) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << function << ": System call failed with code " << retcode << ": " << - strerror(retcode) << std::endl; + sif::warning << function << ": System call failed with code " << retcode << ": " + << strerror(retcode) << std::endl; #endif } diff --git a/linux/utility/utility.h b/linux/utility/utility.h index 3eb17a9b..8f7df04f 100644 --- a/linux/utility/utility.h +++ b/linux/utility/utility.h @@ -1,9 +1,10 @@ #ifndef LINUX_UTILITY_UTILITY_H_ #define LINUX_UTILITY_UTILITY_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + namespace utility { void handleSystemError(int retcode, std::string function); diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 538e63f3..cd8c8b22 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,49 +1,42 @@ #include "ThermalController.h" + #include -ThermalController::ThermalController(object_id_t objectId): - ExtendedControllerBase(objectId, objects::NO_OBJECT), - thermalControllerSet(objectId) { +ThermalController::ThermalController(object_id_t objectId) + : ExtendedControllerBase(objectId, objects::NO_OBJECT), thermalControllerSet(objectId) {} + +ReturnValue_t ThermalController::handleCommandMessage(CommandMessage *message) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ThermalController::handleCommandMessage( - CommandMessage *message) { - return HasReturnvaluesIF::RETURN_OK; -} +void ThermalController::performControlOperation() {} -void ThermalController::performControlOperation() { - -} - -void ThermalController::handleChangedDataset(sid_t sid, - store_address_t storeId) { - if(sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER, - TSensorDefinitions::THERMAL_SENSOR_SET_ID)) { - sif::info << "Update registered!" << std::endl; - } +void ThermalController::handleChangedDataset(sid_t sid, store_address_t storeId) { + if (sid == sid_t(TSensorDefinitions::ObjIds::TEST_HKB_HANDLER, + TSensorDefinitions::THERMAL_SENSOR_SET_ID)) { + sif::info << "Update registered!" << std::endl; + } } ReturnValue_t ThermalController::initializeAfterTaskCreation() { - ReturnValue_t result = - ExtendedControllerBase::initializeAfterTaskCreation(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "ThermalController::initializeAfterTaskCreation: Base" - << " class initialization failed!" << std::endl; - } - HasLocalDataPoolIF* testHkbHandler = ObjectManager::instance()->get( - TSensorDefinitions::ObjIds::TEST_HKB_HANDLER); - if(testHkbHandler == nullptr) { - sif::warning << "ThermalController::initializeAfterTaskCreation: Test" - << " HKB Handler invalid!" << std::endl; - } - // Test normal notifications without data packet first. - testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages( - TSensorDefinitions::THERMAL_SENSOR_SET_ID, - this->getObjectId(), commandQueue->getId(), false); - return result; + ReturnValue_t result = ExtendedControllerBase::initializeAfterTaskCreation(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "ThermalController::initializeAfterTaskCreation: Base" + << " class initialization failed!" << std::endl; + } + HasLocalDataPoolIF *testHkbHandler = ObjectManager::instance()->get( + TSensorDefinitions::ObjIds::TEST_HKB_HANDLER); + if (testHkbHandler == nullptr) { + sif::warning << "ThermalController::initializeAfterTaskCreation: Test" + << " HKB Handler invalid!" << std::endl; + } + // Test normal notifications without data packet first. + testHkbHandler->getHkManagerHandle()->subscribeForSetUpdateMessages( + TSensorDefinitions::THERMAL_SENSOR_SET_ID, this->getObjectId(), commandQueue->getId(), false); + return result; } -ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, - Submode_t submode, uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 67c5b24a..2d76ce8d 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -2,32 +2,30 @@ #define MISSION_CONTROLLER_THERMALCONTROLLER_H_ #include + #include "ctrldefinitions/ThermalCtrlPackets.h" +class ThermalController : public ExtendedControllerBase { + public: + ThermalController(object_id_t objectId); -class ThermalController: public ExtendedControllerBase { -public: - ThermalController(object_id_t objectId); -private: + private: + // TODO: Add stubs for thermal components. Each device / assembly with one + // or multiple redundant sensors will have a thermal component. - // TODO: Add stubs for thermal components. Each device / assembly with one - // or multiple redundant sensors will have a thermal component. + /** ExtendedControllerBase overrides */ + virtual ReturnValue_t handleCommandMessage(CommandMessage *message) override; - /** ExtendedControllerBase overrides */ - virtual ReturnValue_t handleCommandMessage( - CommandMessage *message) override; + virtual void performControlOperation() override; - virtual void performControlOperation() override; + virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) override; - virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) override; + ReturnValue_t initializeAfterTaskCreation() override; - ReturnValue_t initializeAfterTaskCreation() override; + void handleChangedDataset(sid_t sid, store_address_t storeId) override; - void handleChangedDataset(sid_t sid, store_address_t storeId) override; - - ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet; + ThermalCtrl::ThermalControllerTemperatureSet thermalControllerSet; }; - #endif /* MISSION_CONTROLLER_THERMALCONTROLLER_H_ */ diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 14c8791a..b17812e6 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -1,11 +1,6 @@ #include "GenericFactory.h" #include - -#include -#include -#include "objects/systemObjectList.h" - #include #include #include @@ -13,8 +8,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -23,12 +18,16 @@ #include #include #include +#include +#include + +#include "objects/systemObjectList.h" #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TCP_BRIDGE == 0 // UDP server includes -#include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#include "fsfw/osal/common/UdpTmTcBridge.h" #else // TCP server includes #include "fsfw/osal/common/TcpTmTcBridge.h" @@ -41,78 +40,69 @@ #endif void ObjectFactory::produceGenericObjects() { - // Framework objects - new EventManager(objects::EVENT_MANAGER); - new HealthTable(objects::HEALTH_TABLE); - new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - new TimeStamper(objects::TIME_STAMPER); + // Framework objects + new EventManager(objects::EVENT_MANAGER); + new HealthTable(objects::HEALTH_TABLE); + new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + new TimeStamper(objects::TIME_STAMPER); - { - PoolManager::LocalPoolConfig poolCfg = { - {300, 16}, {300, 32}, {200, 64}, {200, 128}, {100, 1024}, {10, 2048} - }; - new PoolManager(objects::TC_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {200, 64}, + {200, 128}, {100, 1024}, {10, 2048}}; + new PoolManager(objects::TC_STORE, poolCfg); + } - { - PoolManager::LocalPoolConfig poolCfg = { - {300, 16}, {300, 32}, {100, 64}, {100, 128}, {100, 1024}, {10, 2048} - }; - new PoolManager(objects::TM_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {100, 64}, + {100, 128}, {100, 1024}, {10, 2048}}; + new PoolManager(objects::TM_STORE, poolCfg); + } - { - PoolManager::LocalPoolConfig poolCfg = { - { 300, 16 }, { 200, 32 }, { 150, 64 }, - { 150, 128 }, { 100, 256 }, { 50, 512 }, { 50, 1024 }, { 10, 2048 } - }; - new PoolManager(objects::IPC_STORE, poolCfg); - } + { + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, + {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; + new PoolManager(objects::IPC_STORE, poolCfg); + } - new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR); - new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR, - objects::CCSDS_PACKET_DISTRIBUTOR); + new CCSDSDistributor(apid::EIVE_OBSW, objects::CCSDS_PACKET_DISTRIBUTOR); + new PUSDistributor(apid::EIVE_OBSW, objects::PUS_PACKET_DISTRIBUTOR, + objects::CCSDS_PACKET_DISTRIBUTOR); + // Every TM packet goes through this funnel + new TmFunnel(objects::TM_FUNNEL); - // Every TM packet goes through this funnel - new TmFunnel(objects::TM_FUNNEL); - - // PUS service stack - new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, - apid::EIVE_OBSW, pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); - new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, - apid::EIVE_OBSW, pus::PUS_SERVICE_2, 3, 10); - new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, - apid::EIVE_OBSW, pus::PUS_SERVICE_3); - new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, - apid::EIVE_OBSW, pus::PUS_SERVICE_5, 50); - new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_8, 3, 60); - new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_9); - new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, - pus::PUS_SERVICE_17); - new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW, - pus::PUS_SERVICE_20); - new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, - apid::EIVE_OBSW, pus::PUS_SERVICE_200); - + // PUS service stack + new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::EIVE_OBSW, + pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); + new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::EIVE_OBSW, + pus::PUS_SERVICE_2, 3, 10); + new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::EIVE_OBSW, + pus::PUS_SERVICE_3); + new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW, + pus::PUS_SERVICE_5, 50); + new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::EIVE_OBSW, + pus::PUS_SERVICE_8, 3, 60); + new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9); + new Service17Test(objects::PUS_SERVICE_17_TEST, apid::EIVE_OBSW, pus::PUS_SERVICE_17); + new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::EIVE_OBSW, + pus::PUS_SERVICE_20); + new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::EIVE_OBSW, + pus::PUS_SERVICE_200); #if OBSW_ADD_TCPIP_BRIDGE == 1 #if OBSW_USE_TCP_BRIDGE == 0 - auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created UDP server for TMTC commanding with listener port " << - udpBridge->getUdpPort() << std::endl; + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created UDP server for TMTC commanding with listener port " + << udpBridge->getUdpPort() << std::endl; #else - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - // TCP is stream based. Use packet ID as start marker when parsing for space packets - tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); - sif::info << "Created TCP server for TMTC commanding with listener port " + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + // TCP is stream based. Use packet ID as start marker when parsing for space packets + tcpServer->setSpacePacketParsingOptions({common::PUS_PACKET_ID}); + sif::info << "Created TCP server for TMTC commanding with listener port " << tcpServer->getTcpPort() << std::endl; #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ - tmtcBridge->setMaxNumberOfPacketsStored(70); + tmtcBridge->setMaxNumberOfPacketsStored(70); #endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ - } diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index c96c7818..1a3b1300 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -5,8 +5,6 @@ namespace ObjectFactory { void produceGenericObjects(); - } - #endif /* MISSION_CORE_GENERICFACTORY_H_ */ diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 955b1703..239a0c7a 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -1,308 +1,309 @@ #include "ACUHandler.h" + #include "OBSWConfig.h" -ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS, - ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset), acuHkTableDataset( - this) { -} +ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS, + ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset), + acuHkTableDataset(this) {} -ACUHandler::~ACUHandler() { -} +ACUHandler::~ACUHandler() {} -ReturnValue_t ACUHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +ReturnValue_t ACUHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void ACUHandler::fillCommandAndReplyMap() { - GomspaceDeviceHandler::fillCommandAndReplyMap(); - this->insertInCommandMap(PRINT_CHANNEL_STATS); + GomspaceDeviceHandler::fillCommandAndReplyMap(); + this->insertInCommandMap(PRINT_CHANNEL_STATS); } void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - handleDeviceTM(&acuHkTableDataset, id, true); + parseHkTableReply(packet); + handleDeviceTM(&acuHkTableDataset, id, true); #if OBSW_ENHANCED_PRINTOUT == 1 && OBSW_DEBUG_ACU == 1 - acuHkTableDataset.read(); - float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1; - float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1; - float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1; - sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl; - sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl; - sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl; - sif::info << "ACU: Ground Watchdog Timer Count: " - << acuHkTableDataset.wdtCntGnd.value << std::endl; - sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " - << acuHkTableDataset.wdtGndLeft.value << std::endl; - acuHkTableDataset.commit(); + acuHkTableDataset.read(); + float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1; + float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1; + float temperatureC_3 = acuHkTableDataset.temperature3.value * 0.1; + sif::info << "ACU: Temperature 1: " << temperatureC_1 << " °C" << std::endl; + sif::info << "ACU: Temperature 2: " << temperatureC_2 << " °C" << std::endl; + sif::info << "ACU: Temperature 3: " << temperatureC_3 << " °C" << std::endl; + sif::info << "ACU: Ground Watchdog Timer Count: " << acuHkTableDataset.wdtCntGnd.value + << std::endl; + sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " + << acuHkTableDataset.wdtGndLeft.value << std::endl; + acuHkTableDataset.commit(); #endif } void ACUHandler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - acuHkTableDataset.read(); - dataOffset += 12; - acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + acuHkTableDataset.read(); + dataOffset += 12; + acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.currentInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.voltageInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.voltageInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.temperature3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.mpptMode = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.mpptMode = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.vboostInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.vboostInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.powerInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.powerInChannel5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.dac0Enable = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.dac1Enable = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.dac2Enable = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.dac0Enable = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.dac1Enable = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.dac2Enable = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.dacRawChannelVal0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal4 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.dacRawChannelVal5 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - /* +12 because here starts the second csp packet */ - dataOffset += 2 + 12; + acuHkTableDataset.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + /* +12 because here starts the second csp packet */ + dataOffset += 2 + 12; - acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + acuHkTableDataset.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - acuHkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - acuHkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + acuHkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + acuHkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; + acuHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + acuHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; - acuHkTableDataset.commit(); + acuHkTableDataset.commit(); } -ReturnValue_t ACUHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_CURRENT_IN_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBAT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_TEMPERATURE_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_MPPT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_VBOOST_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_POWER_CHANNEL5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_EN_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DAC_RAW_5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_RESET_CAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_MPPT_TIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_MPPT_PERIOD, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::ACU_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::ACU_WDT_GND_LEFT, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - switch(cmd) { + switch (cmd) { case PRINT_CHANNEL_STATS: { - printChannelStats(); - return RETURN_OK; + printChannelStats(); + return RETURN_OK; } default: { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } + } } void ACUHandler::printChannelStats() { - PoolReadGuard pg(&acuHkTableDataset); - sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; - sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel0.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel1.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel2.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel3.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel4.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; - sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " << - static_cast(acuHkTableDataset.currentInChannel5.value) << - std::setw(15) << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; + PoolReadGuard pg(&acuHkTableDataset); + sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; + sif::info << std::setw(8) << std::left << "Ch0" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel0.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel0.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch1" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel1.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel1.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch2" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel2.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel2.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch3" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel3.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel3.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch4" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel4.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel4.value << std::endl; + sif::info << std::setw(8) << std::left << "Ch5" << std::dec << "| " + << static_cast(acuHkTableDataset.currentInChannel5.value) << std::setw(15) + << std::right << acuHkTableDataset.voltageInChannel5.value << std::endl; } diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 2bb688e7..0d93c5fe 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -1,51 +1,50 @@ #ifndef MISSION_DEVICES_ACUHANDLER_H_ #define MISSION_DEVICES_ACUHANDLER_H_ -#include "GomspaceDeviceHandler.h" #include + +#include "GomspaceDeviceHandler.h" #include "fsfw/datapool/PoolReadGuard.h" /** * @brief Handler for the ACU from Gomspace. Monitors and controls the battery charging via * the solar panels. */ -class ACUHandler: public GomspaceDeviceHandler { -public: - ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~ACUHandler(); +class ACUHandler : public GomspaceDeviceHandler { + public: + ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~ACUHandler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: + protected: + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual void fillCommandAndReplyMap() override; - virtual void fillCommandAndReplyMap() override; + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; + private: + static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; -private: + ACU::HkTableDataset acuHkTableDataset; - static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; + /** + * @brief Function extracts the hk table information from the received csp packet and stores + * the values in the acuHkTableDataset. + */ + void parseHkTableReply(const uint8_t* packet); - ACU::HkTableDataset acuHkTableDataset; - - /** - * @brief Function extracts the hk table information from the received csp packet and stores - * the values in the acuHkTableDataset. - */ - void parseHkTableReply(const uint8_t *packet); - - /** - * @brief Prints channel statistics (current and voltage) to console - */ - void printChannelStats(); + /** + * @brief Prints channel statistics (current and voltage) to console + */ + void printChannelStats(); }; #endif /* MISSION_DEVICES_ACUHANDLER_H_ */ diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index a0036867..d49b9db4 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -1,6 +1,6 @@ #include "GPSHyperionHandler.h" -#include "devicedefinitions/GPSDefinitions.h" +#include "devicedefinitions/GPSDefinitions.h" #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" @@ -17,165 +17,160 @@ #endif GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentId, - bool debugHyperionGps): - ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), - debugHyperionGps(debugHyperionGps) { -} + bool debugHyperionGps) + : ExtendedControllerBase(objectId, objects::NO_OBJECT), + gpsSet(this), + debugHyperionGps(debugHyperionGps) {} GPSHyperionHandler::~GPSHyperionHandler() {} void GPSHyperionHandler::performControlOperation() { #ifdef FSFW_OSAL_LINUX - readGpsDataFromGpsd(); + readGpsDataFromGpsd(); #endif } -LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { - return nullptr; -} +LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t *data, size_t size) { - switch(actionId) { - case(GpsHyperion::TRIGGER_RESET_PIN): { - if(resetCallback != nullptr) { - PoolReadGuard pg(&gpsSet); - // Set HK entries invalid - gpsSet.setValidity(false, true); - resetCallback(resetCallbackArgs); - return HasActionsIF::EXECUTION_FINISHED; - } - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + const uint8_t *data, size_t size) { + switch (actionId) { + case (GpsHyperion::TRIGGER_RESET_PIN): { + if (resetCallback != nullptr) { + PoolReadGuard pg(&gpsSet); + // Set HK entries invalid + gpsSet.setValidity(false, true); + resetCallback(resetCallbackArgs); + return HasActionsIF::EXECUTION_FINISHED; + } + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); - localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); - localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0})); - localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::HOURS, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::MINUTES, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); - poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::HOURS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::MINUTES, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); + return HasReturnvaluesIF::RETURN_OK; } -void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, - void *args) { - this->resetCallback = resetCallback; - resetCallbackArgs = args; +void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void *args) { + this->resetCallback = resetCallback; + resetCallbackArgs = args; } - ReturnValue_t GPSHyperionHandler::initialize() { - ReturnValue_t result = ExtendedControllerBase::initialize(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + ReturnValue_t result = ExtendedControllerBase::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { return result; + } + return result; } ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) { - return ExtendedControllerBase::handleCommandMessage(message); + return ExtendedControllerBase::handleCommandMessage(message); } #ifdef FSFW_OSAL_LINUX void GPSHyperionHandler::readGpsDataFromGpsd() { - // The data from the device will generally be read all at once. Therefore, we - // can set all field here - gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); - gps_data_t* gps; - gps = gpsmm.read(); - if(gps == nullptr) { - sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; - } - PoolReadGuard pg(&gpsSet); - if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + // The data from the device will generally be read all at once. Therefore, we + // can set all field here + gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); + gps_data_t *gps; + gps = gpsmm.read(); + if (gps == nullptr) { + sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; + } + PoolReadGuard pg(&gpsSet); + if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { #if FSFW_VERBOSE_LEVEL >= 1 - sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" - << std::endl; + sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" << std::endl; #endif - } - // Print messages - if((gps->set & MODE_SET) != MODE_SET) { - // Could not even set mode - gpsSet.setValidity(false, true); - return; - } + } + // Print messages + if ((gps->set & MODE_SET) != MODE_SET) { + // Could not even set mode + gpsSet.setValidity(false, true); + return; + } - if(gps->satellites_used > 0) { - gpsSet.setValidity(true, true); - } + if (gps->satellites_used > 0) { + gpsSet.setValidity(true, true); + } - gpsSet.satInUse.value = gps->satellites_used; - gpsSet.satInView.value = gps->satellites_visible; + gpsSet.satInUse.value = gps->satellites_used; + gpsSet.satInView.value = gps->satellites_visible; - // 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix - gpsSet.fixMode = gps->fix.mode; - if(std::isfinite(gps->fix.latitude)) { - // Negative latitude -> South direction - gpsSet.latitude.value = gps->fix.latitude; - } else { - gpsSet.latitude.setValid(false); - } + // 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix + gpsSet.fixMode = gps->fix.mode; + if (std::isfinite(gps->fix.latitude)) { + // Negative latitude -> South direction + gpsSet.latitude.value = gps->fix.latitude; + } else { + gpsSet.latitude.setValid(false); + } - if(std::isfinite(gps->fix.longitude)) { - // Negative longitude -> West direction - gpsSet.longitude.value = gps->fix.longitude; - } else { - gpsSet.longitude.setValid(false); - } + if (std::isfinite(gps->fix.longitude)) { + // Negative longitude -> West direction + gpsSet.longitude.value = gps->fix.longitude; + } else { + gpsSet.longitude.setValid(false); + } - if(std::isfinite(gps->fix.altitude)) { - gpsSet.altitude.value = gps->fix.altitude; - } else { - gpsSet.altitude.setValid(false); - } + if (std::isfinite(gps->fix.altitude)) { + gpsSet.altitude.value = gps->fix.altitude; + } else { + gpsSet.altitude.setValid(false); + } - if(std::isfinite(gps->fix.speed)) { - gpsSet.speed.value = gps->fix.speed; - } else { - gpsSet.speed.setValid(false); - } + if (std::isfinite(gps->fix.speed)) { + gpsSet.speed.value = gps->fix.speed; + } else { + gpsSet.speed.setValid(false); + } - gpsSet.unixSeconds.value = gps->fix.time.tv_sec; - timeval time = {}; - time.tv_sec = gpsSet.unixSeconds.value; - time.tv_usec = gps->fix.time.tv_nsec / 1000; - Clock::TimeOfDay_t timeOfDay = {}; - Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); - gpsSet.year = timeOfDay.year; - gpsSet.month = timeOfDay.month; - gpsSet.day = timeOfDay.day; - gpsSet.hours = timeOfDay.hour; - gpsSet.minutes = timeOfDay.minute; - gpsSet.seconds = timeOfDay.second; - if(debugHyperionGps) { - sif::info << "-- Hyperion GPS Data --" << std::endl; - time_t timeRaw = gps->fix.time.tv_sec; - std::tm* time = gmtime(&timeRaw); - std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl; - std::cout << "Visible satellites: " << gps->satellites_visible << std::endl; - std::cout << "Satellites used: " << gps->satellites_used << std::endl; - std::cout << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; - std::cout << "Latitude: " << gps->fix.latitude << std::endl; - std::cout << "Longitude: " << gps->fix.longitude << std::endl; - std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl; - std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; - } + gpsSet.unixSeconds.value = gps->fix.time.tv_sec; + timeval time = {}; + time.tv_sec = gpsSet.unixSeconds.value; + time.tv_usec = gps->fix.time.tv_nsec / 1000; + Clock::TimeOfDay_t timeOfDay = {}; + Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); + gpsSet.year = timeOfDay.year; + gpsSet.month = timeOfDay.month; + gpsSet.day = timeOfDay.day; + gpsSet.hours = timeOfDay.hour; + gpsSet.minutes = timeOfDay.minute; + gpsSet.seconds = timeOfDay.second; + if (debugHyperionGps) { + sif::info << "-- Hyperion GPS Data --" << std::endl; + time_t timeRaw = gps->fix.time.tv_sec; + std::tm *time = gmtime(&timeRaw); + std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl; + std::cout << "Visible satellites: " << gps->satellites_visible << std::endl; + std::cout << "Satellites used: " << gps->satellites_used << std::endl; + std::cout << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; + std::cout << "Latitude: " << gps->fix.latitude << std::endl; + std::cout << "Longitude: " << gps->fix.longitude << std::endl; + std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl; + std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; + } } #endif diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index 96d6089e..026e1779 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -1,10 +1,10 @@ #ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_ #define MISSION_DEVICES_GPSHYPERIONHANDLER_H_ -#include "fsfw/FSFW.h" -#include "fsfw/devicehandlers/DeviceHandlerBase.h" -#include "fsfw/controller/ExtendedControllerBase.h" #include "devicedefinitions/GPSDefinitions.h" +#include "fsfw/FSFW.h" +#include "fsfw/controller/ExtendedControllerBase.h" +#include "fsfw/devicehandlers/DeviceHandlerBase.h" /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -12,38 +12,35 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 */ -class GPSHyperionHandler: public ExtendedControllerBase { -public: +class GPSHyperionHandler : public ExtendedControllerBase { + public: + GPSHyperionHandler(object_id_t objectId, object_id_t parentId, bool debugHyperionGps = false); + virtual ~GPSHyperionHandler(); - GPSHyperionHandler(object_id_t objectId, object_id_t parentId, - bool debugHyperionGps = false); - virtual ~GPSHyperionHandler(); + using gpioResetFunction_t = ReturnValue_t (*)(void* args); - using gpioResetFunction_t = ReturnValue_t (*) (void* args); + void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void* args); + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + void performControlOperation() override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + ReturnValue_t initialize() override; - void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void*args); - ReturnValue_t handleCommandMessage(CommandMessage *message) override; - void performControlOperation() override; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) override; - ReturnValue_t executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, - size_t size) override; - ReturnValue_t initialize() override; -protected: + protected: + gpioResetFunction_t resetCallback = nullptr; + void* resetCallbackArgs = nullptr; - gpioResetFunction_t resetCallback = nullptr; - void* resetCallbackArgs = nullptr; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + private: + GpsPrimaryDataset gpsSet; + bool debugHyperionGps = false; -private: - GpsPrimaryDataset gpsSet; - bool debugHyperionGps = false; - - void readGpsDataFromGpsd(); + void readGpsDataFromGpsd(); }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index 95e35a5e..eea1368a 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -2,411 +2,397 @@ #include GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset) : - DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(maxConfigTableAddress), - maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize), - hkTableDataset(hkTableDataset) { - if (comCookie == nullptr) { - sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" - << std::endl; - } - if (hkTableDataset == nullptr) { - sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set" - << std::endl; - } + CookieIF* comCookie, uint16_t maxConfigTableAddress, + uint16_t maxHkTableAddress, uint16_t hkTableReplySize, + LocalPoolDataSetBase* hkTableDataset) + : DeviceHandlerBase(objectId, comIF, comCookie), + maxConfigTableAddress(maxConfigTableAddress), + maxHkTableAddress(maxHkTableAddress), + hkTableReplySize(hkTableReplySize), + hkTableDataset(hkTableDataset) { + if (comCookie == nullptr) { + sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" << std::endl; + } + if (hkTableDataset == nullptr) { + sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set" + << std::endl; + } } -GomspaceDeviceHandler::~GomspaceDeviceHandler() { +GomspaceDeviceHandler::~GomspaceDeviceHandler() {} + +void GomspaceDeviceHandler::doStartUp() {} + +void GomspaceDeviceHandler::doShutDown() {} + +ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; } - -void GomspaceDeviceHandler::doStartUp(){ +ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::doShutDown(){ - -} - -ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - ReturnValue_t result; - switch(deviceCommand) { - case(GOMSPACE::PING): { - result = generatePingCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - break; +ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result; + switch (deviceCommand) { + case (GOMSPACE::PING): { + result = generatePingCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::REBOOT): { - generateRebootCommand(); - break; + case (GOMSPACE::REBOOT): { + generateRebootCommand(); + break; } - case(GOMSPACE::PARAM_SET):{ - result = generateSetParamCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::PARAM_SET): { + result = generateSetParamCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::PARAM_GET):{ - result = generateGetParamCommand(commandData, commandDataLen); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::PARAM_GET): { + result = generateGetParamCommand(commandData, commandDataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::GNDWDT_RESET): { - result = generateResetWatchdogCmd(); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::GNDWDT_RESET): { + result = generateResetWatchdogCmd(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } - case(GOMSPACE::PRINT_SWITCH_V_I): { - result = printStatus(deviceCommand); - break; + case (GOMSPACE::PRINT_SWITCH_V_I): { + result = printStatus(deviceCommand); + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - result = generateRequestFullHkTableCmd(hkTableReplySize); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + result = generateRequestFullHkTableCmd(hkTableReplySize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + break; } default: - return deviceSpecificCommand(deviceCommand); - } - return HasReturnvaluesIF::RETURN_OK; + return deviceSpecificCommand(deviceCommand); + } + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::fillCommandAndReplyMap(){ - this->insertInCommandAndReplyMap(GOMSPACE::PING, 3); - this->insertInCommandMap(GOMSPACE::REBOOT); - this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3); - this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3); - this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3); - this->insertInCommandMap(GOMSPACE::GNDWDT_RESET); - this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I); +void GomspaceDeviceHandler::fillCommandAndReplyMap() { + this->insertInCommandAndReplyMap(GOMSPACE::PING, 3); + this->insertInCommandMap(GOMSPACE::REBOOT); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3); + this->insertInCommandMap(GOMSPACE::GNDWDT_RESET); + this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I); } -ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - switch(rememberCommandId) { - case(GOMSPACE::PING): - *foundId = GOMSPACE::PING; - *foundLen = PING_REPLY_SIZE; - rememberCommandId = GOMSPACE::NONE; - break; - case(GOMSPACE::PARAM_GET): { - *foundId = GOMSPACE::PARAM_GET; - *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GOMSPACE::NONE; - break; +ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + switch (rememberCommandId) { + case (GOMSPACE::PING): + *foundId = GOMSPACE::PING; + *foundLen = PING_REPLY_SIZE; + rememberCommandId = GOMSPACE::NONE; + break; + case (GOMSPACE::PARAM_GET): { + *foundId = GOMSPACE::PARAM_GET; + *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; + rememberCommandId = GOMSPACE::NONE; + break; } - case(GOMSPACE::PARAM_SET): { - *foundId = GOMSPACE::PARAM_SET; - *foundLen = rememberRequestedSize; - rememberCommandId = GOMSPACE::NONE; - break; + case (GOMSPACE::PARAM_SET): { + *foundId = GOMSPACE::PARAM_SET; + *foundLen = rememberRequestedSize; + rememberCommandId = GOMSPACE::NONE; + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - *foundId = GOMSPACE::REQUEST_HK_TABLE; - *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GOMSPACE::NONE; - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + *foundId = GOMSPACE::REQUEST_HK_TABLE; + *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; + rememberCommandId = GOMSPACE::NONE; + break; } default: - return IGNORE_REPLY_DATA; - } - return HasReturnvaluesIF::RETURN_OK; + return IGNORE_REPLY_DATA; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch(id) { - case(GOMSPACE::PING): { - SerializeElement replyTime = *packet; - handleDeviceTM(&replyTime, id, true); - break; + const uint8_t* packet) { + switch (id) { + case (GOMSPACE::PING): { + SerializeElement replyTime = *packet; + handleDeviceTM(&replyTime, id, true); + break; } - case(GOMSPACE::PARAM_GET): { - // -2 to subtract address size from gomspace parameter reply packet - uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2; - if(payloadLength > sizeof(uint32_t)){ - sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload " - << "size in reply" << std::endl; - return INVALID_PAYLOAD_SIZE; - } - uint8_t tempPayloadBuffer[payloadLength]; - /* Extract information from received data */ - CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength); - size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength; - ReturnValue_t result = cspGetParamReply.deSerialize(&packet, &size, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter" - << "reply" << std::endl; - return result; - } - uint8_t action = cspGetParamReply.getAction(); - uint8_t tableId = cspGetParamReply.getTableId(); - uint16_t address = cspGetParamReply.getAddress(); - /* Pack relevant information into a tm packet */ - ParamReply paramReply(action, tableId, address, payloadLength, - tempPayloadBuffer); - handleDeviceTM(¶mReply, id, true); - break; + case (GOMSPACE::PARAM_GET): { + // -2 to subtract address size from gomspace parameter reply packet + uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2; + if (payloadLength > sizeof(uint32_t)) { + sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload " + << "size in reply" << std::endl; + return INVALID_PAYLOAD_SIZE; + } + uint8_t tempPayloadBuffer[payloadLength]; + /* Extract information from received data */ + CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength); + size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength; + ReturnValue_t result = + cspGetParamReply.deSerialize(&packet, &size, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter" + << "reply" << std::endl; + return result; + } + uint8_t action = cspGetParamReply.getAction(); + uint8_t tableId = cspGetParamReply.getTableId(); + uint16_t address = cspGetParamReply.getAddress(); + /* Pack relevant information into a tm packet */ + ParamReply paramReply(action, tableId, address, payloadLength, tempPayloadBuffer); + handleDeviceTM(¶mReply, id, true); + break; } - case(GOMSPACE::PARAM_SET): { - /* When setting a parameter, the p60dock sends back the state of the - * operation */ - if(*packet != PARAM_SET_OK){ - return HasReturnvaluesIF::RETURN_FAILED; - } - break; + case (GOMSPACE::PARAM_SET): { + /* When setting a parameter, the p60dock sends back the state of the + * operation */ + if (*packet != PARAM_SET_OK) { + return HasReturnvaluesIF::RETURN_FAILED; + } + break; } - case(GOMSPACE::REQUEST_HK_TABLE): { - letChildHandleHkReply(id, packet); - break; + case (GOMSPACE::REQUEST_HK_TABLE): { + letChildHandleHkReply(id, packet); + break; } default: - break; - } - return HasReturnvaluesIF::RETURN_OK; + break; + } + return HasReturnvaluesIF::RETURN_OK; } -void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid(){ +void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid() {} +ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* commandData, + size_t commandDataLen) { + SetParamMessageUnpacker setParamMessageUnpacker; + ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, &commandDataLen, + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " + "message" + << std::endl; + return result; + } + /* Get and check address */ + uint16_t address = setParamMessageUnpacker.getAddress(); + if (address > maxConfigTableAddress) { + sif::error << "GomspaceDeviceHandler: Invalid address for set parameter " + << "action" << std::endl; + return INVALID_ADDRESS; + } + uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; + uint16_t seq = 0; + uint16_t total = 0; + /* CSP reply only contains the transaction state */ + uint16_t querySize = 1; + const uint8_t* parameterPtr = setParamMessageUnpacker.getParameter(); + uint8_t parameterSize = setParamMessageUnpacker.getParameterSize(); + uint16_t payloadlength = sizeof(address) + parameterSize; + + /* Generate command for CspComIF */ + CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, total, address, + parameterPtr, parameterSize); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize command for " + << "CspComIF" << std::endl; + return result; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Invalid length of set parameter " + "command" + << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::PARAM_SET; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand( - const uint8_t * commandData, size_t commandDataLen) { - SetParamMessageUnpacker setParamMessageUnpacker; - ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, - &commandDataLen, SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " - "message" << std::endl; - return result; - } - /* Get and check address */ - uint16_t address = setParamMessageUnpacker.getAddress(); - if(address > maxConfigTableAddress){ - sif::error << "GomspaceDeviceHandler: Invalid address for set parameter " - << "action" << std::endl; - return INVALID_ADDRESS; - } - uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; - uint16_t seq = 0; - uint16_t total = 0; - /* CSP reply only contains the transaction state */ - uint16_t querySize = 1; - const uint8_t* parameterPtr = setParamMessageUnpacker.getParameter(); - uint8_t parameterSize = setParamMessageUnpacker.getParameterSize(); - uint16_t payloadlength = sizeof(address) + parameterSize; +ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result; + /* Unpack the received action message */ + GetParamMessageUnpacker getParamMessage; + result = getParamMessage.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Failed to deserialize message to extract information " + "from get parameter message" + << std::endl; + return result; + } + /* Get an check table id to read from */ + uint8_t tableId = getParamMessage.getTableId(); + if (tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter" + " message" + << std::endl; + return INVALID_TABLE_ID; + } + /* Get and check address */ + uint16_t address = getParamMessage.getAddress(); + if (address > maxHkTableAddress && tableId == HK_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " + << "housekeeping table" << std::endl; + return INVALID_ADDRESS; + } + if (address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID) { + sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " + << "configuration table" << std::endl; + return INVALID_ADDRESS; + } + uint16_t length = sizeof(address); + uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; + uint16_t seq = 0; + uint16_t total = 0; + uint8_t parameterSize = getParamMessage.getParameterSize(); + if (parameterSize > sizeof(uint32_t)) { + sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter " + << "size" << std::endl; + return INVALID_PARAM_SIZE; + } + uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH; - /* Generate command for CspComIF */ - CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, - total, address, parameterPtr, parameterSize); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), - SerializeIF::Endianness::BIG); - - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize command for " - << "CspComIF" << std::endl; - return result; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Invalid length of set parameter " - "command" << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::PARAM_SET; - return HasReturnvaluesIF::RETURN_OK; + /* Generate the CSP command to send to the P60 Dock */ + CspGetParamCommand getParamCmd(querySize, tableId, length, checksum, seq, total, address); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize command to " + << "get parameter" << std::endl; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Received invalid get parameter " + "command" + << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::PARAM_GET; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand( - const uint8_t * commandData, size_t commandDataLen){ - ReturnValue_t result; - /* Unpack the received action message */ - GetParamMessageUnpacker getParamMessage; - result = getParamMessage.deSerialize(&commandData, &commandDataLen, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Failed to deserialize message to extract information " - "from get parameter message" << std::endl; - return result; - } - /* Get an check table id to read from */ - uint8_t tableId = getParamMessage.getTableId(); - if(tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter" - " message" << std::endl; - return INVALID_TABLE_ID; - } - /* Get and check address */ - uint16_t address = getParamMessage.getAddress(); - if(address > maxHkTableAddress && tableId == HK_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " - << "housekeeping table" << std::endl; - return INVALID_ADDRESS; - } - if(address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID){ - sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from " - << "configuration table" << std::endl; - return INVALID_ADDRESS; - } - uint16_t length = sizeof(address); - uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM; - uint16_t seq = 0; - uint16_t total = 0; - uint8_t parameterSize = getParamMessage.getParameterSize(); - if(parameterSize > sizeof(uint32_t)) { - sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter " - << "size" << std::endl; - return INVALID_PARAM_SIZE; - } - uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH; - - /* Generate the CSP command to send to the P60 Dock */ - CspGetParamCommand getParamCmd(querySize, tableId, length, - checksum, seq, total, address); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize command to " - << "get parameter" << std::endl; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Received invalid get parameter " - "command" << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::PARAM_GET; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GomspaceDeviceHandler::generatePingCommand(const uint8_t* commandData, + size_t commandDataLen) { + CspPingCommand cspPingCommand(commandData, commandDataLen); + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" << std::endl; + return result; + } + if (cspPacketLen > MAX_PACKET_LEN) { + sif::error << "GomspaceDeviceHandler: Received invalid ping message" << std::endl; + return PACKET_TOO_LONG; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberCommandId = GOMSPACE::PING; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GomspaceDeviceHandler::generatePingCommand( - const uint8_t * commandData, size_t commandDataLen) { - CspPingCommand cspPingCommand(commandData, commandDataLen); - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, - sizeof(cspPacket), - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" - << std::endl; - return result; - } - if(cspPacketLen > MAX_PACKET_LEN){ - sif::error << "GomspaceDeviceHandler: Received invalid ping message" - << std::endl; - return PACKET_TOO_LONG; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberCommandId = GOMSPACE::PING; - return HasReturnvaluesIF::RETURN_OK; +void GomspaceDeviceHandler::generateRebootCommand() { + uint8_t cspPort = GOMSPACE::REBOOT_PORT; + uint16_t querySize = 0; + *cspPacket = GOMSPACE::REBOOT_PORT; + *(cspPacket + 1) = querySize; + size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen); + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; } -void GomspaceDeviceHandler::generateRebootCommand(){ - uint8_t cspPort = GOMSPACE::REBOOT_PORT; - uint16_t querySize = 0; - *cspPacket = GOMSPACE::REBOOT_PORT; - *(cspPacket + 1) = querySize; - size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen); - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; -} - -ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd(){ - WatchdogResetCommand watchdogResetCommand; - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = watchdogResetCommand.serialize(&buffer, - &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset " - << "command" << std::endl; - return result; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = 0; // No bytes will be queried with the ground - // watchdog command. - rememberCommandId = GOMSPACE::GNDWDT_RESET; - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() { + WatchdogResetCommand watchdogResetCommand; + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = watchdogResetCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), + SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset " + << "command" << std::endl; + return result; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = 0; // No bytes will be queried with the ground + // watchdog command. + rememberCommandId = GOMSPACE::GNDWDT_RESET; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTableReplySize) { + uint16_t querySize = hkTableReplySize; + uint8_t tableId = HK_TABLE_ID; + RequestFullTableCommand requestFullTableCommand(querySize, tableId); - uint16_t querySize = hkTableReplySize; - uint8_t tableId = HK_TABLE_ID; - RequestFullTableCommand requestFullTableCommand(querySize, tableId); - - size_t cspPacketLen = 0; - uint8_t* buffer = cspPacket; - ReturnValue_t result = requestFullTableCommand.serialize(&buffer, - &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize " - "full table request command " << std::endl; - return result; - } - rawPacket = cspPacket; - rawPacketLen = cspPacketLen; - rememberRequestedSize = querySize; - rememberCommandId = GOMSPACE::REQUEST_HK_TABLE; - return RETURN_OK; + size_t cspPacketLen = 0; + uint8_t* buffer = cspPacket; + ReturnValue_t result = requestFullTableCommand.serialize( + &buffer, &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize " + "full table request command " + << std::endl; + return result; + } + rawPacket = cspPacket; + rawPacketLen = cspPacketLen; + rememberRequestedSize = querySize; + rememberCommandId = GOMSPACE::REQUEST_HK_TABLE; + return RETURN_OK; } -uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, - Mode_t modeTo) { - return 0; -} +uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; } LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) { - if(sid == hkTableDataset->getSid()) { - return hkTableDataset; - } - else { - return nullptr; - } + if (sid == hkTableDataset->getSid()) { + return hkTableDataset; + } else { + return nullptr; + } } ReturnValue_t GomspaceDeviceHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } -void GomspaceDeviceHandler::setModeNormal() { - mode = MODE_NORMAL; -} +void GomspaceDeviceHandler::setModeNormal() { mode = MODE_NORMAL; } ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) { - sif::info << "No printHkTable implementation given.." << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::info << "No printHkTable implementation given.." << std::endl; + return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 29156fce..c9c08609 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -16,135 +16,125 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Gomspace_PCDU_P60_System */ -class GomspaceDeviceHandler: public DeviceHandlerBase { -public: +class GomspaceDeviceHandler : public DeviceHandlerBase { + public: + static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER; + static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); + static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); + static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); + static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); + static const ReturnValue_t INVALID_PAYLOAD_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); + static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5); - static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER; - static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); - static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); - static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); - static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); - static const ReturnValue_t INVALID_PAYLOAD_SIZE = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); - static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5); + /** + * @brief Constructor + * + * @param maxConfigTableAddress The maximum memory address of the configu- + * ration table of a gomspace device. + * @param maxHkTableAddress The maximum memory address of a value in the + * houskeeping (telemetry) table of a gomspace + * device. + */ + GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, + uint16_t hkTableReplySize, LocalPoolDataSetBase *hkTableDataset); + virtual ~GomspaceDeviceHandler(); - /** - * @brief Constructor - * - * @param maxConfigTableAddress The maximum memory address of the configu- - * ration table of a gomspace device. - * @param maxHkTableAddress The maximum memory address of a value in the - * houskeeping (telemetry) table of a gomspace - * device. - */ - GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset); - virtual ~GomspaceDeviceHandler(); + /** + * @brief This function can be used to set a gomspace device to normal mode immediately after + * object creation. + */ + void setModeNormal(); - /** - * @brief This function can be used to set a gomspace device to normal mode immediately after - * object creation. - */ - void setModeNormal(); + protected: + static const uint8_t MAX_PACKET_LEN = 36; + static const uint8_t PARAM_SET_OK = 1; + static const uint8_t PING_REPLY_SIZE = 2; + static const uint8_t CONFIG_TABLE_ID = 1; + static const uint8_t HK_TABLE_ID = 4; -protected: + uint8_t rememberRequestedSize = 0; + uint8_t rememberCommandId = GOMSPACE::NONE; + uint8_t cspPacket[MAX_PACKET_LEN]; - static const uint8_t MAX_PACKET_LEN = 36; - static const uint8_t PARAM_SET_OK = 1; - static const uint8_t PING_REPLY_SIZE = 2; - static const uint8_t CONFIG_TABLE_ID = 1; - static const uint8_t HK_TABLE_ID = 4; + uint16_t maxConfigTableAddress; + uint16_t maxHkTableAddress; - uint8_t rememberRequestedSize = 0; - uint8_t rememberCommandId = GOMSPACE::NONE; - uint8_t cspPacket[MAX_PACKET_LEN]; + /** The size of the reply following a full hk table request.*/ + uint16_t hkTableReplySize; - uint16_t maxConfigTableAddress; - uint16_t maxHkTableAddress; + LocalPoolDataSetBase *hkTableDataset = nullptr; - /** The size of the reply following a full hk table request.*/ - uint16_t hkTableReplySize; + void doStartUp() override; + void doShutDown() override; + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + virtual 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; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + /** + * @brief The command to generate a request to receive the full housekeeping table is device + * specific. Thus the child has to build this command. + */ + virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize); - LocalPoolDataSetBase* hkTableDataset = nullptr; + /** + * This command handles printing the HK table to the console. This is useful for debugging + * purposes + * @return + */ + virtual ReturnValue_t printStatus(DeviceCommandId_t cmd); - void doStartUp() override; - void doShutDown() override; - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) - override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - virtual 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; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - /** - * @brief The command to generate a request to receive the full housekeeping table is device - * specific. Thus the child has to build this command. - */ - virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize); + /** + * @brief Because housekeeping tables are device specific the handling of the reply is + * given to the child class. + * @param id The id of the command which initiates the full table request. + * @param packet Pointer to the reply containing the hk table. + */ + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0; - /** - * This command handles printing the HK table to the console. This is useful for debugging - * purposes - * @return - */ - virtual ReturnValue_t printStatus(DeviceCommandId_t cmd); + virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; - /** - * @brief Because housekeeping tables are device specific the handling of the reply is - * given to the child class. - * @param id The id of the command which initiates the full table request. - * @param packet Pointer to the reply containing the hk table. - */ - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0; + /** + * @brief Can be used by gomspace devices to implement device specific commands. + */ + virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + private: + /** + * @brief Function to generate the command to set a parameter. Command + * will be sent to the ComIF over the rawPacket buffer. + */ + ReturnValue_t generateSetParamCommand(const uint8_t *commandData, size_t commandDataLen); - /** - * @brief Can be used by gomspace devices to implement device specific commands. - */ - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); + /** + * @brief Function to generate the command to get a parameter from a + * gomspace device. Command will be sent to the ComIF over the + * rawPacket buffer. + */ + ReturnValue_t generateGetParamCommand(const uint8_t *commandData, size_t commandDataLen); -private: + /** + * @brief Function to generate the ping command for the ComIF. + */ + ReturnValue_t generatePingCommand(const uint8_t *commandData, size_t commandDataLen); - /** - * @brief Function to generate the command to set a parameter. Command - * will be sent to the ComIF over the rawPacket buffer. - */ - ReturnValue_t generateSetParamCommand(const uint8_t * commandData, - size_t commandDataLen); - - /** - * @brief Function to generate the command to get a parameter from a - * gomspace device. Command will be sent to the ComIF over the - * rawPacket buffer. - */ - ReturnValue_t generateGetParamCommand(const uint8_t * commandData, - size_t commandDataLen); - - /** - * @brief Function to generate the ping command for the ComIF. - */ - ReturnValue_t generatePingCommand(const uint8_t * commandData, - size_t commandDataLen); - - /** - * @brief Function to generate the command to reboot a gomspace device - * via the ComIF. - */ - void generateRebootCommand(); - - /** - * @brief Function to generate the command to force a ground watchdog - * reset in a gomspace device. - */ - ReturnValue_t generateResetWatchdogCmd(); + /** + * @brief Function to generate the command to reboot a gomspace device + * via the ComIF. + */ + void generateRebootCommand(); + /** + * @brief Function to generate the command to force a ground watchdog + * reset in a gomspace device. + */ + ReturnValue_t generateResetWatchdogCmd(); }; #endif /* MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ */ diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 4820eefc..7ea76758 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -1,481 +1,482 @@ #include "GyroADIS1650XHandler.h" + #include #include #if OBSW_ADIS1650X_LINUX_COM_IF == 1 -#include "fsfw_hal/linux/utility.h" -#include "fsfw_hal/linux/spi/SpiCookie.h" -#include "fsfw_hal/linux/spi/SpiComIF.h" -#include "fsfw_hal/linux/UnixFileGuard.h" #include #include + +#include "fsfw_hal/linux/UnixFileGuard.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "fsfw_hal/linux/utility.h" #endif -GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, - object_id_t deviceCommunication, CookieIF * comCookie, ADIS1650X::Type type): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), adisType(type), - primaryDataset(this), configDataset(this), breakCountdown() { +GyroADIS1650XHandler::GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, + CookieIF *comCookie, ADIS1650X::Type type) + : DeviceHandlerBase(objectId, deviceCommunication, comCookie), + adisType(type), + primaryDataset(this), + configDataset(this), + breakCountdown() { #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - debugDivider = new PeriodicOperationDivider(5); + debugDivider = new PeriodicOperationDivider(5); #endif #if OBSW_ADIS1650X_LINUX_COM_IF == 1 - SpiCookie* cookie = dynamic_cast(comCookie); - if(cookie != nullptr) { - cookie->setCallbackMode(&spiSendCallback, this); - } + SpiCookie *cookie = dynamic_cast(comCookie); + if (cookie != nullptr) { + cookie->setCallbackMode(&spiSendCallback, this); + } #endif } void GyroADIS1650XHandler::doStartUp() { - // Initial 310 ms start up time after power-up - if(internalState == InternalState::STARTUP) { - if(not commandExecuted) { - breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); - commandExecuted = true; - } - if(breakCountdown.hasTimedOut()) { - internalState = InternalState::CONFIG; - commandExecuted = false; - } + // Initial 310 ms start up time after power-up + if (internalState == InternalState::STARTUP) { + if (not commandExecuted) { + breakCountdown.setTimeout(ADIS1650X::START_UP_TIME); + commandExecuted = true; } + if (breakCountdown.hasTimedOut()) { + internalState = InternalState::CONFIG; + commandExecuted = false; + } + } - // Read all configuration registers first - if(internalState == InternalState::CONFIG) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::IDLE; - } + // Read all configuration registers first + if (internalState == InternalState::CONFIG) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::IDLE; } + } - if(internalState == InternalState::IDLE) { - setMode(MODE_NORMAL); - // setMode(MODE_ON); - } + if (internalState == InternalState::IDLE) { + setMode(MODE_NORMAL); + // setMode(MODE_ON); + } } void GyroADIS1650XHandler::doShutDown() { - commandExecuted = false; - setMode(_MODE_POWER_DOWN); + commandExecuted = false; + setMode(_MODE_POWER_DOWN); } ReturnValue_t GyroADIS1650XHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - *id = ADIS1650X::READ_SENSOR_DATA; - return buildCommandFromCommand(*id, nullptr, 0); + *id = ADIS1650X::READ_SENSOR_DATA; + return buildCommandFromCommand(*id, nullptr, 0); } ReturnValue_t GyroADIS1650XHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - switch(internalState) { - case(InternalState::CONFIG): { - *id = ADIS1650X::READ_OUT_CONFIG; - buildCommandFromCommand(*id, nullptr, 0); - break; + switch (internalState) { + case (InternalState::CONFIG): { + *id = ADIS1650X::READ_OUT_CONFIG; + buildCommandFromCommand(*id, nullptr, 0); + break; } - case(InternalState::STARTUP): { - return NOTHING_TO_SEND; - break; + case (InternalState::STARTUP): { + return NOTHING_TO_SEND; + break; } default: { - /* Might be a configuration error. */ - sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: " - "Unknown internal state!" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + /* Might be a configuration error. */ + sif::debug << "GyroADIS16507Handler::buildTransitionDeviceCommand: " + "Unknown internal state!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GyroADIS1650XHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) { - switch(deviceCommand) { - case(ADIS1650X::READ_OUT_CONFIG): { - this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; - uint8_t regList[5]; - regList[0] = ADIS1650X::DIAG_STAT_REG; - regList[1] = ADIS1650X::FILTER_CTRL_REG; - regList[2] = ADIS1650X::MSC_CTRL_REG; - regList[3] = ADIS1650X::DEC_RATE_REG; - regList[4] = ADIS1650X::PROD_ID_REG; - prepareReadCommand(regList, sizeof(regList)); - this->rawPacket = commandBuffer.data(); - break; + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (ADIS1650X::READ_OUT_CONFIG): { + this->rawPacketLen = ADIS1650X::CONFIG_READOUT_SIZE; + uint8_t regList[5]; + regList[0] = ADIS1650X::DIAG_STAT_REG; + regList[1] = ADIS1650X::FILTER_CTRL_REG; + regList[2] = ADIS1650X::MSC_CTRL_REG; + regList[3] = ADIS1650X::DEC_RATE_REG; + regList[4] = ADIS1650X::PROD_ID_REG; + prepareReadCommand(regList, sizeof(regList)); + this->rawPacket = commandBuffer.data(); + break; } - case(ADIS1650X::READ_SENSOR_DATA): { - if(breakCountdown.isBusy()) { - // A glob command is pending and sensor data can't be read currently - return NO_REPLY_EXPECTED; - } - std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(), - ADIS1650X::BURST_READ_ENABLE.size()); - std::memset(commandBuffer.data() + 2, 0, 10 * 2); - this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE; - this->rawPacket = commandBuffer.data(); - break; + case (ADIS1650X::READ_SENSOR_DATA): { + if (breakCountdown.isBusy()) { + // A glob command is pending and sensor data can't be read currently + return NO_REPLY_EXPECTED; + } + std::memcpy(commandBuffer.data(), ADIS1650X::BURST_READ_ENABLE.data(), + ADIS1650X::BURST_READ_ENABLE.size()); + std::memset(commandBuffer.data() + 2, 0, 10 * 2); + this->rawPacketLen = ADIS1650X::SENSOR_READOUT_SIZE; + this->rawPacket = commandBuffer.data(); + break; } - case(ADIS1650X::SELF_TEST_SENSORS): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00); - breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK); - break; + case (ADIS1650X::SELF_TEST_SENSORS): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SENSOR_SELF_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::SELF_TEST_BREAK); + break; } - case(ADIS1650X::SELF_TEST_MEMORY): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00); - breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK); - break; + case (ADIS1650X::SELF_TEST_MEMORY): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_TEST, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_TEST_BREAK); + break; } - case(ADIS1650X::UPDATE_NV_CONFIGURATION): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); - breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK); - break; + case (ADIS1650X::UPDATE_NV_CONFIGURATION): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FLASH_MEMORY_UPDATE, 0x00); + breakCountdown.setTimeout(ADIS1650X::FLASH_MEMORY_UPDATE_BREAK); + break; } - case(ADIS1650X::RESET_SENSOR_CONFIGURATION): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00); - breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK); - break; + case (ADIS1650X::RESET_SENSOR_CONFIGURATION): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::FACTORY_CALIBRATION, 0x00); + breakCountdown.setTimeout(ADIS1650X::FACTORY_CALIBRATION_BREAK); + break; } - case(ADIS1650X::SW_RESET): { - if(breakCountdown.isBusy()) { - // Another glob command is pending - return HasActionsIF::IS_BUSY; - } - prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00); - breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK); - break; + case (ADIS1650X::SW_RESET): { + if (breakCountdown.isBusy()) { + // Another glob command is pending + return HasActionsIF::IS_BUSY; + } + prepareWriteCommand(ADIS1650X::GLOB_CMD, ADIS1650X::GlobCmds::SOFTWARE_RESET, 0x00); + breakCountdown.setTimeout(ADIS1650X::SW_RESET_BREAK); + break; } - case(ADIS1650X::PRINT_CURRENT_CONFIGURATION): { + case (ADIS1650X::PRINT_CURRENT_CONFIGURATION): { #if OBSW_VERBOSE_LEVEL >= 1 - PoolReadGuard pg(&configDataset); - sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) << - std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl; - sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x" << - configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x" << - configDataset.filterSetting.value << " | DEC_RATE: 0x" << - configDataset.decRateReg.value << std::setfill(' ') << std::endl; + PoolReadGuard pg(&configDataset); + sif::info << "ADIS16507 Sensor configuration: DIAG_STAT: 0x" << std::hex << std::setw(4) + << std::setfill('0') << "0x" << configDataset.diagStatReg.value << std::endl; + sif::info << "MSC_CTRL: " << std::hex << std::setw(4) << "0x" + << configDataset.mscCtrlReg.value << " | FILT_CTRL: 0x" + << configDataset.filterSetting.value << " | DEC_RATE: 0x" + << configDataset.decRateReg.value << std::setfill(' ') << std::endl; #endif /* OBSW_VERBOSE_LEVEL >= 1 */ } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } void GyroADIS1650XHandler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset); - insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset); - insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1); - insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1); - insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1); - insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1); - insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::READ_SENSOR_DATA, 1, &primaryDataset); + insertInCommandAndReplyMap(ADIS1650X::READ_OUT_CONFIG, 1, &configDataset); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_SENSORS, 1); + insertInCommandAndReplyMap(ADIS1650X::SELF_TEST_MEMORY, 1); + insertInCommandAndReplyMap(ADIS1650X::UPDATE_NV_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::RESET_SENSOR_CONFIGURATION, 1); + insertInCommandAndReplyMap(ADIS1650X::SW_RESET, 1); + insertInCommandAndReplyMap(ADIS1650X::PRINT_CURRENT_CONFIGURATION, 1); } ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { - // For SPI, the ID will always be the one of the last sent command - *foundId = this->getPendingCommand(); - *foundLen = this->rawPacketLen; + DeviceCommandId_t *foundId, size_t *foundLen) { + // For SPI, the ID will always be the one of the last sent command + *foundId = this->getPendingCommand(); + *foundLen = this->rawPacketLen; - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch(id) { - case(ADIS1650X::READ_OUT_CONFIG): { - - uint16_t readProdId = packet[10] << 8 | packet[11]; - if(((adisType == ADIS1650X::Type::ADIS16507) and - (readProdId != ADIS1650X::PROD_ID_16507)) or - ((adisType == ADIS1650X::Type::ADIS16505) and - (readProdId != ADIS1650X::PROD_ID_16505))) { + const uint8_t *packet) { + switch (id) { + case (ADIS1650X::READ_OUT_CONFIG): { + uint16_t readProdId = packet[10] << 8 | packet[11]; + if (((adisType == ADIS1650X::Type::ADIS16507) and (readProdId != ADIS1650X::PROD_ID_16507)) or + ((adisType == ADIS1650X::Type::ADIS16505) and (readProdId != ADIS1650X::PROD_ID_16505))) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " - << readProdId << std::endl; + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " + << readProdId << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; - } - PoolReadGuard rg(&configDataset); - configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; - configDataset.filterSetting.value = packet[4] << 8 | packet[5]; - configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; - configDataset.decRateReg.value = packet[8] << 8 | packet[9]; - configDataset.setValidity(true, true); - if(internalState == InternalState::CONFIG) { - commandExecuted = true; - } - break; + return HasReturnvaluesIF::RETURN_FAILED; + } + PoolReadGuard rg(&configDataset); + configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; + configDataset.filterSetting.value = packet[4] << 8 | packet[5]; + configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; + configDataset.decRateReg.value = packet[8] << 8 | packet[9]; + configDataset.setValidity(true, true); + if (internalState == InternalState::CONFIG) { + commandExecuted = true; + } + break; } - case(ADIS1650X::READ_SENSOR_DATA): { - return handleSensorData(packet); + case (ADIS1650X::READ_SENSOR_DATA): { + return handleSensorData(packet); } - - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { - BurstModes burstMode = getBurstMode(); - switch(burstMode) { - case(BurstModes::BURST_16_BURST_SEL_1): - case(BurstModes::BURST_32_BURST_SEL_1): { - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" - " not implemented!" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + BurstModes burstMode = getBurstMode(); + switch (burstMode) { + case (BurstModes::BURST_16_BURST_SEL_1): + case (BurstModes::BURST_32_BURST_SEL_1): { + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" + " not implemented!" + << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - case(BurstModes::BURST_16_BURST_SEL_0): { - uint16_t checksum = packet[20] << 8 | packet[21]; - // Now verify the read checksum with the expected checksum according to datasheet p. 20 - uint16_t calcChecksum = 0; - for(size_t idx = 2; idx < 20; idx ++) { - calcChecksum += packet[idx]; - } - if(checksum != calcChecksum) { + case (BurstModes::BURST_16_BURST_SEL_0): { + uint16_t checksum = packet[20] << 8 | packet[21]; + // Now verify the read checksum with the expected checksum according to datasheet p. 20 + uint16_t calcChecksum = 0; + for (size_t idx = 2; idx < 20; idx++) { + calcChecksum += packet[idx]; + } + if (checksum != calcChecksum) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " - "Invalid checksum detected!" << std::endl; + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " + "Invalid checksum detected!" + << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_FAILED; + } + + ReturnValue_t result = configDataset.diagStatReg.read(); + if (result == HasReturnvaluesIF::RETURN_OK) { + configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; + configDataset.diagStatReg.setValid(true); + } + configDataset.diagStatReg.commit(); + + { + PoolReadGuard pg(&primaryDataset); + int16_t angVelocXRaw = packet[4] << 8 | packet[5]; + primaryDataset.angVelocX.value = + static_cast(angVelocXRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + int16_t angVelocYRaw = packet[6] << 8 | packet[7]; + primaryDataset.angVelocY.value = + static_cast(angVelocYRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + int16_t angVelocZRaw = packet[8] << 8 | packet[9]; + primaryDataset.angVelocZ.value = + static_cast(angVelocZRaw) / INT16_MAX * ADIS1650X::GYRO_RANGE; + + float accelScaling = 0; + if (adisType == ADIS1650X::Type::ADIS16507) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507; + } else if (adisType == ADIS1650X::Type::ADIS16505) { + accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; + } else { + sif::warning << "GyroADIS1650XHandler::handleSensorData: " + "Unknown ADIS type" + << std::endl; } + int16_t accelXRaw = packet[10] << 8 | packet[11]; + primaryDataset.accelX.value = static_cast(accelXRaw) / INT16_MAX * accelScaling; + int16_t accelYRaw = packet[12] << 8 | packet[13]; + primaryDataset.accelY.value = static_cast(accelYRaw) / INT16_MAX * accelScaling; + int16_t accelZRaw = packet[14] << 8 | packet[15]; + primaryDataset.accelZ.value = static_cast(accelZRaw) / INT16_MAX * accelScaling; - ReturnValue_t result = configDataset.diagStatReg.read(); - if(result == HasReturnvaluesIF::RETURN_OK) { - configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; - configDataset.diagStatReg.setValid(true); - } - configDataset.diagStatReg.commit(); - - { - PoolReadGuard pg(&primaryDataset); - int16_t angVelocXRaw = packet[4] << 8 | packet[5]; - primaryDataset.angVelocX.value = static_cast(angVelocXRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - int16_t angVelocYRaw = packet[6] << 8 | packet[7]; - primaryDataset.angVelocY.value = static_cast(angVelocYRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - int16_t angVelocZRaw = packet[8] << 8 | packet[9]; - primaryDataset.angVelocZ.value = static_cast(angVelocZRaw) / INT16_MAX * - ADIS1650X::GYRO_RANGE; - - float accelScaling = 0; - if(adisType == ADIS1650X::Type::ADIS16507) { - accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16507; - } else if(adisType == ADIS1650X::Type::ADIS16505) { - accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; - } else { - sif::warning << "GyroADIS1650XHandler::handleSensorData: " - "Unknown ADIS type" << std::endl; - } - int16_t accelXRaw = packet[10] << 8 | packet[11]; - primaryDataset.accelX.value = static_cast(accelXRaw) / INT16_MAX * - accelScaling; - int16_t accelYRaw = packet[12] << 8 | packet[13]; - primaryDataset.accelY.value = static_cast(accelYRaw) / INT16_MAX * - accelScaling; - int16_t accelZRaw = packet[14] << 8 | packet[15]; - primaryDataset.accelZ.value = static_cast(accelZRaw) / INT16_MAX * - accelScaling; - - int16_t temperatureRaw = packet[16] << 8 | packet[17]; - primaryDataset.temperature.value = static_cast(temperatureRaw) * 0.1; - // Ignore data counter for now - primaryDataset.setValidity(true, true); - } + int16_t temperatureRaw = packet[16] << 8 | packet[17]; + primaryDataset.temperature.value = static_cast(temperatureRaw) * 0.1; + // Ignore data counter for now + primaryDataset.setValidity(true, true); + } #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - if(debugDivider->checkAndIncrement()) { - sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; - sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; - sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; - sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; - sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; - sif::info << "X: " << primaryDataset.accelX.value << std::endl; - sif::info << "Y: " << primaryDataset.accelY.value << std::endl; - sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; - } + if (debugDivider->checkAndIncrement()) { + sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; + sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; + sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; + sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; + sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; + sif::info << "X: " << primaryDataset.accelX.value << std::endl; + sif::info << "Y: " << primaryDataset.accelY.value << std::endl; + sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; + } #endif - break; + break; } - case(BurstModes::BURST_32_BURST_SEL_0): { - break; + case (BurstModes::BURST_32_BURST_SEL_0): { + break; } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 10000; + return 10000; } void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, - uint8_t valueTwo) { - uint8_t secondReg = startReg + 1; - startReg |= ADIS1650X::WRITE_MASK; - secondReg |= ADIS1650X::WRITE_MASK; - commandBuffer[0] = startReg; - commandBuffer[1] = valueOne; - commandBuffer[2] = secondReg; - commandBuffer[3] = valueTwo; - this->rawPacketLen = 4; - this->rawPacket = commandBuffer.data(); + uint8_t valueTwo) { + uint8_t secondReg = startReg + 1; + startReg |= ADIS1650X::WRITE_MASK; + secondReg |= ADIS1650X::WRITE_MASK; + commandBuffer[0] = startReg; + commandBuffer[1] = valueOne; + commandBuffer[2] = secondReg; + commandBuffer[3] = valueTwo; + this->rawPacketLen = 4; + this->rawPacket = commandBuffer.data(); } void GyroADIS1650XHandler::prepareReadCommand(uint8_t *regList, size_t len) { - for(size_t idx = 0; idx < len; idx++) { - commandBuffer[idx * 2] = regList[idx]; - commandBuffer[idx * 2 + 1] = 0x00; - } - commandBuffer[len * 2] = 0x00; - commandBuffer[len * 2 + 1] = 0x00; + for (size_t idx = 0; idx < len; idx++) { + commandBuffer[idx * 2] = regList[idx]; + commandBuffer[idx * 2 + 1] = 0x00; + } + commandBuffer[len * 2] = 0x00; + commandBuffer[len * 2 + 1] = 0x00; } ReturnValue_t GyroADIS1650XHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry({0.0})); + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ANG_VELOC_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_X, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Y, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::ACCELERATION_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(ADIS1650X::TEMPERATURE, new PoolEntry({0.0})); - localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); - localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); - return HasReturnvaluesIF::RETURN_OK; + localDataPoolMap.emplace(ADIS1650X::DIAG_STAT_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); + localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); + return HasReturnvaluesIF::RETURN_OK; } GyroADIS1650XHandler::BurstModes GyroADIS1650XHandler::getBurstMode() { - configDataset.mscCtrlReg.read(); - uint16_t currentCtrlReg = configDataset.mscCtrlReg.value; - configDataset.mscCtrlReg.commit(); - if((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) { - if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { - return BurstModes::BURST_32_BURST_SEL_1; - } - else { - return BurstModes::BURST_32_BURST_SEL_0; - } + configDataset.mscCtrlReg.read(); + uint16_t currentCtrlReg = configDataset.mscCtrlReg.value; + configDataset.mscCtrlReg.commit(); + if ((currentCtrlReg & ADIS1650X::BURST_32_BIT) == ADIS1650X::BURST_32_BIT) { + if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { + return BurstModes::BURST_32_BURST_SEL_1; + } else { + return BurstModes::BURST_32_BURST_SEL_0; } - else { - if((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { - return BurstModes::BURST_16_BURST_SEL_1; - } - else { - return BurstModes::BURST_16_BURST_SEL_0; - } + } else { + if ((currentCtrlReg & ADIS1650X::BURST_SEL_BIT) == ADIS1650X::BURST_SEL_BIT) { + return BurstModes::BURST_16_BURST_SEL_1; + } else { + return BurstModes::BURST_16_BURST_SEL_0; } + } } #if OBSW_ADIS1650X_LINUX_COM_IF == 1 ReturnValue_t GyroADIS1650XHandler::spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, - const uint8_t *sendData, size_t sendLen, void *args) { - GyroADIS1650XHandler* handler = reinterpret_cast(args); - if(handler == nullptr) { - sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!" - << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + const uint8_t *sendData, size_t sendLen, + void *args) { + GyroADIS1650XHandler *handler = reinterpret_cast(args); + if (handler == nullptr) { + sif::error << "GyroADIS16507Handler::spiSendCallback: Passed handler pointer is invalid!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + DeviceCommandId_t currentCommand = handler->getPendingCommand(); + switch (currentCommand) { + case (ADIS1650X::READ_SENSOR_DATA): { + return comIf->performRegularSendOperation(cookie, sendData, sendLen); } - DeviceCommandId_t currentCommand = handler->getPendingCommand(); - switch(currentCommand) { - case(ADIS1650X::READ_SENSOR_DATA): { - return comIf->performRegularSendOperation(cookie, sendData, sendLen); - } - case(ADIS1650X::READ_OUT_CONFIG): + case (ADIS1650X::READ_OUT_CONFIG): default: { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - int retval = 0; - // Prepare transfer - int fileDescriptor = 0; - std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); - if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { - return SpiComIF::OPENING_FILE_FAILED; - } - spi::SpiModes spiMode = spi::SpiModes::MODE_0; - uint32_t spiSpeed = 0; - cookie->getSpiParameters(spiMode, spiSpeed, nullptr); - comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); - cookie->assignWriteBuffer(sendData); - cookie->setTransferSize(2); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + int retval = 0; + // Prepare transfer + int fileDescriptor = 0; + std::string device = cookie->getSpiDevice(); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); + if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + return SpiComIF::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie->getSpiParameters(spiMode, spiSpeed, nullptr); + comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + cookie->assignWriteBuffer(sendData); + cookie->setTransferSize(2); - gpioId_t gpioId = cookie->getChipSelectPin(); - GpioIF* gpioIF = comIf->getGpioInterface(); - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t timeoutMs = 0; - MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); - if(mutex == nullptr or gpioIF == nullptr) { + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF *gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF *mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if (mutex == nullptr or gpioIF == nullptr) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS16507Handler::spiSendCallback: " - "Mutex or GPIO interface invalid" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + sif::warning << "GyroADIS16507Handler::spiSendCallback: " + "Mutex or GPIO interface invalid" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; #endif - } + } - if(gpioId != gpio::NO_GPIO) { - result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != RETURN_OK) { + if (gpioId != gpio::NO_GPIO) { + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; + sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; #endif - return result; - } + return result; + } + } + + size_t idx = 0; + while (idx < sendLen) { + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + gpioIF->pullLow(gpioId); } - size_t idx = 0; - while(idx < sendLen) { - // Pull SPI CS low. For now, no support for active high given - if(gpioId != gpio::NO_GPIO) { - gpioIF->pullLow(gpioId); - } - - // Execute transfer - // Initiate a full duplex SPI transfer. - retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle()); - if(retval < 0) { - utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); - result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED; - } + // Execute transfer + // Initiate a full duplex SPI transfer. + retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie->getTransferStructHandle()); + if (retval < 0) { + utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); + result = SpiComIF::FULL_DUPLEX_TRANSFER_FAILED; + } #if FSFW_HAL_SPI_WIRETAPPING == 1 - comIf->performSpiWiretapping(cookie); + comIf->performSpiWiretapping(cookie); #endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */ - if(gpioId != gpio::NO_GPIO) { - gpioIF->pullHigh(gpioId); - } - - idx += 2; - if(idx < sendLen) { - usleep(ADIS1650X::STALL_TIME_MICROSECONDS); - } - spi_ioc_transfer* transferStruct = cookie->getTransferStructHandle(); - transferStruct->tx_buf += 2; - transferStruct->rx_buf += 2; + if (gpioId != gpio::NO_GPIO) { + gpioIF->pullHigh(gpioId); } - if(gpioId != gpio::NO_GPIO) { - mutex->unlockMutex(); + idx += 2; + if (idx < sendLen) { + usleep(ADIS1650X::STALL_TIME_MICROSECONDS); } + spi_ioc_transfer *transferStruct = cookie->getTransferStructHandle(); + transferStruct->tx_buf += 2; + transferStruct->rx_buf += 2; + } + + if (gpioId != gpio::NO_GPIO) { + mutex->unlockMutex(); + } } - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } #endif /* OBSW_ADIS1650X_LINUX_COM_IF == 1 */ diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index b1ac50f5..c1f9ae98 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -1,12 +1,11 @@ #ifndef MISSION_DEVICES_GYROADIS16507HANDLER_H_ #define MISSION_DEVICES_GYROADIS16507HANDLER_H_ -#include "OBSWConfig.h" #include "FSFWConfig.h" +#include "OBSWConfig.h" #include "devicedefinitions/GyroADIS1650XDefinitions.h" - -#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #if OBSW_ADIS1650X_LINUX_COM_IF == 1 class SpiComIF; @@ -19,67 +18,60 @@ class SpiCookie; * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/ADIS16507_Gyro */ -class GyroADIS1650XHandler: public DeviceHandlerBase { -public: - GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie, ADIS1650X::Type type); +class GyroADIS1650XHandler : public DeviceHandlerBase { + public: + GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, + ADIS1650X::Type type); - // DeviceHandlerBase abstract function implementation - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) override; - void fillCommandAndReplyMap() 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; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + // DeviceHandlerBase abstract function implementation + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + void fillCommandAndReplyMap() 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; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; -private: - std::array commandBuffer; - ADIS1650X::Type adisType; - AdisGyroPrimaryDataset primaryDataset; - AdisGyroConfigDataset configDataset; + private: + std::array commandBuffer; + ADIS1650X::Type adisType; + AdisGyroPrimaryDataset primaryDataset; + AdisGyroConfigDataset configDataset; - enum class InternalState { - STARTUP, - CONFIG, - IDLE - }; + enum class InternalState { STARTUP, CONFIG, IDLE }; - enum class BurstModes { - BURST_16_BURST_SEL_0, - BURST_16_BURST_SEL_1, - BURST_32_BURST_SEL_0, - BURST_32_BURST_SEL_1 - }; + enum class BurstModes { + BURST_16_BURST_SEL_0, + BURST_16_BURST_SEL_1, + BURST_32_BURST_SEL_0, + BURST_32_BURST_SEL_1 + }; - InternalState internalState = InternalState::STARTUP; - bool commandExecuted = false; + InternalState internalState = InternalState::STARTUP; + bool commandExecuted = false; - void prepareReadCommand(uint8_t* regList, size_t len); + void prepareReadCommand(uint8_t *regList, size_t len); - BurstModes getBurstMode(); + BurstModes getBurstMode(); #if OBSW_ADIS1650X_LINUX_COM_IF == 1 - static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie, - const uint8_t *sendData, size_t sendLen, void* args); + static ReturnValue_t spiSendCallback(SpiComIF *comIf, SpiCookie *cookie, const uint8_t *sendData, + size_t sendLen, void *args); #endif #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 - PeriodicOperationDivider* debugDivider; + PeriodicOperationDivider *debugDivider; #endif - Countdown breakCountdown; - void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo); + Countdown breakCountdown; + void prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo); - ReturnValue_t handleSensorData(const uint8_t* packet); + ReturnValue_t handleSensorData(const uint8_t *packet); }; - - #endif /* MISSION_DEVICES_GYROADIS16507HANDLER_H_ */ diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 60a60328..572810bd 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -1,373 +1,346 @@ #include "HeaterHandler.h" + +#include +#include +#include + #include "devices/gpioIds.h" #include "devices/powerSwitcherList.h" -#include -#include -#include - HeaterHandler::HeaterHandler(object_id_t setObjectId_, object_id_t gpioDriverId_, - CookieIF * gpioCookie_, object_id_t mainLineSwitcherObjectId_, uint8_t mainLineSwitch_) : - SystemObject(setObjectId_), gpioDriverId(gpioDriverId_), gpioCookie(gpioCookie_), - mainLineSwitcherObjectId(mainLineSwitcherObjectId_), mainLineSwitch(mainLineSwitch_), - actionHelper(this, nullptr) { - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); + CookieIF* gpioCookie_, object_id_t mainLineSwitcherObjectId_, + uint8_t mainLineSwitch_) + : SystemObject(setObjectId_), + gpioDriverId(gpioDriverId_), + gpioCookie(gpioCookie_), + mainLineSwitcherObjectId(mainLineSwitcherObjectId_), + mainLineSwitch(mainLineSwitch_), + actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -HeaterHandler::~HeaterHandler() { -} +HeaterHandler::~HeaterHandler() {} ReturnValue_t HeaterHandler::performOperation(uint8_t operationCode) { - - if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { - readCommandQueue(); - handleActiveCommands(); - return RETURN_OK; - } - return RETURN_OK; + if (operationCode == DeviceHandlerIF::PERFORM_OPERATION) { + readCommandQueue(); + handleActiveCommands(); + return RETURN_OK; + } + return RETURN_OK; } ReturnValue_t HeaterHandler::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = SystemObject::initialize(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = initializeHeaterMap(); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = initializeHeaterMap(); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - gpioInterface = ObjectManager::instance()->get(gpioDriverId); - if (gpioInterface == nullptr) { - sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + gpioInterface = ObjectManager::instance()->get(gpioDriverId); + if (gpioInterface == nullptr) { + sif::error << "HeaterHandler::initialize: Invalid Gpio interface." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = gpioInterface->addGpios(dynamic_cast(gpioCookie)); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::initialize: Failed to initialize Gpio interface" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (IPCStore == nullptr) { - sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (IPCStore == nullptr) { + sif::error << "HeaterHandler::initialize: IPC store not set up in factory." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - if(mainLineSwitcherObjectId != objects::NO_OBJECT) { - mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); - if (mainLineSwitcher == nullptr) { - sif::error - << "HeaterHandler::initialize: Failed to get main line switcher. Make sure " - << "main line switcher object is initialized." << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - } + if (mainLineSwitcherObjectId != objects::NO_OBJECT) { + mainLineSwitcher = ObjectManager::instance()->get(mainLineSwitcherObjectId); + if (mainLineSwitcher == nullptr) { + sif::error << "HeaterHandler::initialize: Failed to get main line switcher. Make sure " + << "main line switcher object is initialized." << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } - result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t HeaterHandler::initializeHeaterMap(){ - HeaterCommandInfo_t heaterCommandInfo; - for(switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo); - if (status.second == false) { - sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map" - << std::endl; - return RETURN_FAILED; - } - } - return RETURN_OK; +ReturnValue_t HeaterHandler::initializeHeaterMap() { + HeaterCommandInfo_t heaterCommandInfo; + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + std::pair status = heaterMap.emplace(switchNr, heaterCommandInfo); + if (status.second == false) { + sif::error << "HeaterHandler::initializeHeaterMap: Failed to initialize heater map" + << std::endl; + return RETURN_FAILED; + } + } + return RETURN_OK; } void HeaterHandler::setInitialSwitchStates() { - for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - switchStates[switchNr] = OFF; - } + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + switchStates[switchNr] = OFF; + } } void HeaterHandler::readCommandQueue() { - CommandMessage command; - ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + CommandMessage command; + ReturnValue_t result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { - return; - } + result = actionHelper.handleActionMessage(&command); + if (result == RETURN_OK) { + return; + } } -ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result; - if (actionId != SWITCH_HEATER) { - result = COMMAND_NOT_SUPPORTED; - } else { - switchNr_t switchNr = *data; - HeaterMapIter heaterMapIter = heaterMap.find(switchNr); - if (heaterMapIter != heaterMap.end()) { - if (heaterMapIter->second.active) { - return COMMAND_ALREADY_WAITING; - } - heaterMapIter->second.action = *(data + 1); - heaterMapIter->second.active = true; - heaterMapIter->second.replyQueue = commandedBy; - } - else { - sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl; - return INVALID_SWITCH_NR; - } - result = RETURN_OK; - } - return result; +ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + ReturnValue_t result; + if (actionId != SWITCH_HEATER) { + result = COMMAND_NOT_SUPPORTED; + } else { + switchNr_t switchNr = *data; + HeaterMapIter heaterMapIter = heaterMap.find(switchNr); + if (heaterMapIter != heaterMap.end()) { + if (heaterMapIter->second.active) { + return COMMAND_ALREADY_WAITING; + } + heaterMapIter->second.action = *(data + 1); + heaterMapIter->second.active = true; + heaterMapIter->second.replyQueue = commandedBy; + } else { + sif::error << "HeaterHandler::executeAction: Invalid switchNr" << std::endl; + return INVALID_SWITCH_NR; + } + result = RETURN_OK; + } + return result; } +void HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const { + ReturnValue_t result; + store_address_t storeAddress; + uint8_t commandData[2]; -void HeaterHandler::sendSwitchCommand(uint8_t switchNr, - ReturnValue_t onOff) const { + switch (onOff) { + case PowerSwitchIF::SWITCH_ON: + commandData[0] = switchNr; + commandData[1] = SET_SWITCH_ON; + break; + case PowerSwitchIF::SWITCH_OFF: + commandData[0] = switchNr; + commandData[1] = SET_SWITCH_OFF; + break; + default: + sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request" << std::endl; + break; + } - ReturnValue_t result; - store_address_t storeAddress; - uint8_t commandData[2]; - - switch(onOff) { - case PowerSwitchIF::SWITCH_ON: - commandData[0] = switchNr; - commandData[1] = SET_SWITCH_ON; - break; - case PowerSwitchIF::SWITCH_OFF: - commandData[0] = switchNr; - commandData[1] = SET_SWITCH_OFF; - break; - default: - sif::error << "HeaterHandler::sendSwitchCommand: Invalid switch request" - << std::endl; - break; - } - - result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData)); - if (result == RETURN_OK) { - CommandMessage message; - ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress); - /* Send heater command to own command queue */ - result = commandQueue->sendMessage(commandQueue->getId(), &message, 0); - if (result != RETURN_OK) { - sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch" - << "message" << std::endl; - } - } + result = IPCStore->addData(&storeAddress, commandData, sizeof(commandData)); + if (result == RETURN_OK) { + CommandMessage message; + ActionMessage::setCommand(&message, SWITCH_HEATER, storeAddress); + /* Send heater command to own command queue */ + result = commandQueue->sendMessage(commandQueue->getId(), &message, 0); + if (result != RETURN_OK) { + sif::debug << "HeaterHandler::sendSwitchCommand: Failed to send switch" + << "message" << std::endl; + } + } } -void HeaterHandler::handleActiveCommands(){ - - HeaterMapIter heaterMapIter = heaterMap.begin(); - for (; heaterMapIter != heaterMap.end(); heaterMapIter++) { - if (heaterMapIter->second.active) { - switch(heaterMapIter->second.action) { - case SET_SWITCH_ON: - handleSwitchOnCommand(heaterMapIter); - break; - case SET_SWITCH_OFF: - handleSwitchOffCommand(heaterMapIter); - break; - default: - sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded" - << std::endl; - break; - } - } - } +void HeaterHandler::handleActiveCommands() { + HeaterMapIter heaterMapIter = heaterMap.begin(); + for (; heaterMapIter != heaterMap.end(); heaterMapIter++) { + if (heaterMapIter->second.active) { + switch (heaterMapIter->second.action) { + case SET_SWITCH_ON: + handleSwitchOnCommand(heaterMapIter); + break; + case SET_SWITCH_OFF: + handleSwitchOffCommand(heaterMapIter); + break; + default: + sif::error << "HeaterHandler::handleActiveCommands: Invalid action commanded" + << std::endl; + break; + } + } + } } void HeaterHandler::handleSwitchOnCommand(HeaterMapIter heaterMapIter) { + ReturnValue_t result = RETURN_OK; + switchNr_t switchNr; - ReturnValue_t result = RETURN_OK; - switchNr_t switchNr; + /* Check if command waits for main switch being set on and whether the timeout has expired */ + if (heaterMapIter->second.waitMainSwitchOn && + heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) { + // TODO - This requires the initiation of an FDIR procedure + triggerEvent(MAIN_SWITCH_TIMEOUT); + sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout" + << std::endl; + heaterMapIter->second.active = false; + heaterMapIter->second.waitMainSwitchOn = false; + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + MAIN_SWITCH_SET_TIMEOUT); + } + return; + } - /* Check if command waits for main switch being set on and whether the timeout has expired */ - if (heaterMapIter->second.waitMainSwitchOn - && heaterMapIter->second.mainSwitchCountdown.hasTimedOut()) { - //TODO - This requires the initiation of an FDIR procedure - triggerEvent(MAIN_SWITCH_TIMEOUT); - sif::error << "HeaterHandler::handleSwitchOnCommand: Main switch setting on timeout" - << std::endl; - heaterMapIter->second.active = false; - heaterMapIter->second.waitMainSwitchOn = false; - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, MAIN_SWITCH_SET_TIMEOUT ); - } - return; + switchNr = heaterMapIter->first; + /* Check state of main line switch */ + ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); + if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { + if (!checkSwitchState(switchNr)) { + gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); + result = gpioInterface->pullHigh(gpioId); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id " << gpioId + << " high" << std::endl; + triggerEvent(GPIO_PULL_HIGH_FAILED, result); + } else { + switchStates[switchNr] = ON; + } + } else { + triggerEvent(SWITCH_ALREADY_ON, switchNr); } - - switchNr = heaterMapIter->first; - /* Check state of main line switch */ - ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); - if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { - if (!checkSwitchState(switchNr)) { - gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); - result = gpioInterface->pullHigh(gpioId); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id " - << gpioId << " high" << std::endl; - triggerEvent(GPIO_PULL_HIGH_FAILED, result); - } - else { - switchStates[switchNr] = ON; - } - } - else { - triggerEvent(SWITCH_ALREADY_ON, switchNr); - } - /* There is no need to send action finish replies if the sender was the - * HeaterHandler itself. */ - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - if(result == RETURN_OK) { - actionHelper.finish(true, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - else { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - - } - heaterMapIter->second.active = false; - heaterMapIter->second.waitMainSwitchOn = false; + /* There is no need to send action finish replies if the sender was the + * HeaterHandler itself. */ + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + if (result == RETURN_OK) { + actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } else { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } } - else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF - && heaterMapIter->second.waitMainSwitchOn) { - /* Just waiting for the main switch being set on */ - return; - } - else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) { - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, - PowerSwitchIF::SWITCH_ON); - heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); - heaterMapIter->second.waitMainSwitchOn = true; - } - else { - sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of" - << " main line switch" << std::endl; - if (heaterMapIter->second.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, mainSwitchState); - } - heaterMapIter->second.active = false; + heaterMapIter->second.active = false; + heaterMapIter->second.waitMainSwitchOn = false; + } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF && + heaterMapIter->second.waitMainSwitchOn) { + /* Just waiting for the main switch being set on */ + return; + } else if (mainSwitchState == PowerSwitchIF::SWITCH_OFF) { + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); + heaterMapIter->second.mainSwitchCountdown.setTimeout(mainLineSwitcher->getSwitchDelayMs()); + heaterMapIter->second.waitMainSwitchOn = true; + } else { + sif::debug << "HeaterHandler::handleActiveCommands: Failed to get state of" + << " main line switch" << std::endl; + if (heaterMapIter->second.replyQueue != commandQueue->getId()) { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + mainSwitchState); } + heaterMapIter->second.active = false; + } } void HeaterHandler::handleSwitchOffCommand(HeaterMapIter heaterMapIter) { - ReturnValue_t result = RETURN_OK; - switchNr_t switchNr = heaterMapIter->first; - /* Check whether switch is already off */ - if (checkSwitchState(switchNr)) { - gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); - result = gpioInterface->pullLow(gpioId); - if (result != RETURN_OK) { - sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id" - << gpioId << " low" << std::endl; - triggerEvent(GPIO_PULL_LOW_FAILED, result); - } - else { - switchStates[switchNr] = OFF; - /* When all switches are off, also main line switch will be turned off */ - if (allSwitchesOff()) { - mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); - } - } + ReturnValue_t result = RETURN_OK; + switchNr_t switchNr = heaterMapIter->first; + /* Check whether switch is already off */ + if (checkSwitchState(switchNr)) { + gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr); + result = gpioInterface->pullLow(gpioId); + if (result != RETURN_OK) { + sif::error << "HeaterHandler::handleSwitchOffCommand: Failed to pull gpio with id" << gpioId + << " low" << std::endl; + triggerEvent(GPIO_PULL_LOW_FAILED, result); + } else { + switchStates[switchNr] = OFF; + /* When all switches are off, also main line switch will be turned off */ + if (allSwitchesOff()) { + mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + } } - else { - sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl; - triggerEvent(SWITCH_ALREADY_OFF, switchNr); + } else { + sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl; + triggerEvent(SWITCH_ALREADY_OFF, switchNr); + } + if (heaterMapIter->second.replyQueue != NO_COMMANDER) { + /* Report back switch command reply if necessary */ + if (result == HasReturnvaluesIF::RETURN_OK) { + actionHelper.finish(true, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); + } else { + actionHelper.finish(false, heaterMapIter->second.replyQueue, heaterMapIter->second.action, + result); } - if (heaterMapIter->second.replyQueue != NO_COMMANDER) { - /* Report back switch command reply if necessary */ - if(result == HasReturnvaluesIF::RETURN_OK) { - actionHelper.finish(true, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - else { - actionHelper.finish(false, heaterMapIter->second.replyQueue, - heaterMapIter->second.action, result); - } - } - heaterMapIter->second.active = false; + } + heaterMapIter->second.active = false; } -bool HeaterHandler::checkSwitchState(int switchNr) { - return switchStates[switchNr]; -} +bool HeaterHandler::checkSwitchState(int switchNr) { return switchStates[switchNr]; } bool HeaterHandler::allSwitchesOff() { - bool allSwitchesOrd = false; - /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ - for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { - allSwitchesOrd = allSwitchesOrd || switchStates[switchNr]; - } - return !allSwitchesOrd; + bool allSwitchesOrd = false; + /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ + for (switchNr_t switchNr = 0; switchNr < heaterSwitches::NUMBER_OF_SWITCHES; switchNr++) { + allSwitchesOrd = allSwitchesOrd || switchStates[switchNr]; + } + return !allSwitchesOrd; } gpioId_t HeaterHandler::getGpioIdFromSwitchNr(int switchNr) { - gpioId_t gpioId = 0xFFFF; - switch(switchNr) { + gpioId_t gpioId = 0xFFFF; + switch (switchNr) { case heaterSwitches::HEATER_0: - gpioId = gpioIds::HEATER_0; - break; + gpioId = gpioIds::HEATER_0; + break; case heaterSwitches::HEATER_1: - gpioId = gpioIds::HEATER_1; - break; + gpioId = gpioIds::HEATER_1; + break; case heaterSwitches::HEATER_2: - gpioId = gpioIds::HEATER_2; - break; + gpioId = gpioIds::HEATER_2; + break; case heaterSwitches::HEATER_3: - gpioId = gpioIds::HEATER_3; - break; + gpioId = gpioIds::HEATER_3; + break; case heaterSwitches::HEATER_4: - gpioId = gpioIds::HEATER_4; - break; + gpioId = gpioIds::HEATER_4; + break; case heaterSwitches::HEATER_5: - gpioId = gpioIds::HEATER_5; - break; + gpioId = gpioIds::HEATER_5; + break; case heaterSwitches::HEATER_6: - gpioId = gpioIds::HEATER_6; - break; + gpioId = gpioIds::HEATER_6; + break; case heaterSwitches::HEATER_7: - gpioId = gpioIds::HEATER_7; - break; + gpioId = gpioIds::HEATER_7; + break; default: - sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number" - << std::endl; - break; - } - return gpioId; + sif::error << "HeaterHandler::getGpioIdFromSwitchNr: Unknown heater switch number" + << std::endl; + break; + } + return gpioId; } -MessageQueueId_t HeaterHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->getId(); } -void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const { -} +void HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) const {} -ReturnValue_t HeaterHandler::getSwitchState( uint8_t switchNr ) const { - return 0; -} +ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { return 0; } -ReturnValue_t HeaterHandler::getFuseState( uint8_t fuseNr ) const { - return 0; -} +ReturnValue_t HeaterHandler::getFuseState(uint8_t fuseNr) const { return 0; } -uint32_t HeaterHandler::getSwitchDelayMs(void) const { - return 0; -} +uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 0; } diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index b52e22d4..2a8ce555 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -1,177 +1,169 @@ #ifndef MISSION_DEVICES_HEATERHANDLER_H_ #define MISSION_DEVICES_HEATERHANDLER_H_ -#include "devices/heaterSwitcherList.h" - -#include -#include -#include #include -#include -#include #include +#include +#include +#include +#include +#include #include #include + #include +#include "devices/heaterSwitcherList.h" + /** * @brief This class intends the control of heaters. * * @author J. Meier */ -class HeaterHandler: public ExecutableObjectIF, - public PowerSwitchIF, - public SystemObject, - public HasActionsIF { -public: - static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; +class HeaterHandler : public ExecutableObjectIF, + public PowerSwitchIF, + public SystemObject, + public HasActionsIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::HEATER_HANDLER; - static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t INIT_FAILED = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t INVALID_SWITCH_NR = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t MAIN_SWITCH_SET_TIMEOUT = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); - /** Device command IDs */ - static const DeviceCommandId_t SWITCH_HEATER = 0x0; + /** Device command IDs */ + static const DeviceCommandId_t SWITCH_HEATER = 0x0; - HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF * gpioCookie, - object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch); + HeaterHandler(object_id_t setObjectId, object_id_t gpioDriverId, CookieIF* gpioCookie, + object_id_t mainLineSwitcherObjectId, uint8_t mainLineSwitch); - virtual ~HeaterHandler(); + virtual ~HeaterHandler(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; - virtual void sendFuseOnCommand(uint8_t fuseNr) const override; - /** - * @brief This function will be called from the Heater object to check - * the current switch state. - */ - virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override; - virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override; - virtual uint32_t getSwitchDelayMs(void) const override; + virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; + virtual void sendFuseOnCommand(uint8_t fuseNr) const override; + /** + * @brief This function will be called from the Heater object to check + * the current switch state. + */ + virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; + virtual uint32_t getSwitchDelayMs(void) const override; - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; - virtual ReturnValue_t initialize() override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + virtual ReturnValue_t initialize() override; -private: + private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; + static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW); + static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW); + static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW); + static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW); + static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER_HANDLER; - static const Event GPIO_PULL_HIGH_FAILED = MAKE_EVENT(0, severity::LOW); - static const Event GPIO_PULL_LOW_FAILED = MAKE_EVENT(1, severity::LOW); - static const Event SWITCH_ALREADY_ON = MAKE_EVENT(2, severity::LOW); - static const Event SWITCH_ALREADY_OFF = MAKE_EVENT(3, severity::LOW); - static const Event MAIN_SWITCH_TIMEOUT = MAKE_EVENT(4, severity::LOW); + static const MessageQueueId_t NO_COMMANDER = 0; - static const MessageQueueId_t NO_COMMANDER = 0; + enum SwitchState : bool { ON = true, OFF = false }; - enum SwitchState : bool { - ON = true, - OFF = false - }; + /** + * @brief Struct holding information about a heater command to execute. + * + * @param action The action to perform. + * @param replyQueue The queue of the commander to which status replies + * will be sent. + * @param active True if command is waiting for execution, otherwise false. + * @param waitSwitchOn True if the command is waiting for the main switch being set on. + * @param mainSwitchCountdown Sets timeout to wait for main switch being set on. + */ + typedef struct HeaterCommandInfo { + uint8_t action; + MessageQueueId_t replyQueue; + bool active = false; + bool waitMainSwitchOn = false; + Countdown mainSwitchCountdown; + } HeaterCommandInfo_t; + enum SwitchAction { SET_SWITCH_OFF, SET_SWITCH_ON }; - /** - * @brief Struct holding information about a heater command to execute. - * - * @param action The action to perform. - * @param replyQueue The queue of the commander to which status replies - * will be sent. - * @param active True if command is waiting for execution, otherwise false. - * @param waitSwitchOn True if the command is waiting for the main switch being set on. - * @param mainSwitchCountdown Sets timeout to wait for main switch being set on. - */ - typedef struct HeaterCommandInfo { - uint8_t action; - MessageQueueId_t replyQueue; - bool active = false; - bool waitMainSwitchOn = false; - Countdown mainSwitchCountdown; - } HeaterCommandInfo_t; + using switchNr_t = uint8_t; + using HeaterMap = std::unordered_map; + using HeaterMapIter = HeaterMap::iterator; - enum SwitchAction { - SET_SWITCH_OFF, - SET_SWITCH_ON - }; + HeaterMap heaterMap; - using switchNr_t = uint8_t; - using HeaterMap = std::unordered_map; - using HeaterMapIter = HeaterMap::iterator; + bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES]; - HeaterMap heaterMap; + /** Size of command queue */ + size_t cmdQueueSize = 20; - bool switchStates[heaterSwitches::NUMBER_OF_SWITCHES]; + /** + * The object ID of the GPIO driver which enables and disables the + * heaters. + */ + object_id_t gpioDriverId; - /** Size of command queue */ - size_t cmdQueueSize = 20; + CookieIF* gpioCookie; - /** - * The object ID of the GPIO driver which enables and disables the - * heaters. - */ - object_id_t gpioDriverId; + GpioIF* gpioInterface = nullptr; - CookieIF * gpioCookie; + /** Queue to receive messages from other objects. */ + MessageQueueIF* commandQueue = nullptr; - GpioIF* gpioInterface = nullptr; + object_id_t mainLineSwitcherObjectId; - /** Queue to receive messages from other objects. */ - MessageQueueIF* commandQueue = nullptr; + /** Switch number of the heater power supply switch */ + uint8_t mainLineSwitch; - object_id_t mainLineSwitcherObjectId; + /** + * Power switcher object which controls the 8V main line of the heater + * logic on the TCS board. + */ + PowerSwitchIF* mainLineSwitcher = nullptr; - /** Switch number of the heater power supply switch */ - uint8_t mainLineSwitch; + ActionHelper actionHelper; - /** - * Power switcher object which controls the 8V main line of the heater - * logic on the TCS board. - */ - PowerSwitchIF *mainLineSwitcher = nullptr; + StorageManagerIF* IPCStore = nullptr; - ActionHelper actionHelper; + void readCommandQueue(); - StorageManagerIF *IPCStore = nullptr; + /** + * @brief Returns the state of a switch (ON - true, or OFF - false). + * @param switchNr The number of the switch to check. + */ + bool checkSwitchState(int switchNr); - void readCommandQueue(); + /** + * @brief Returns the ID of the GPIO related to a heater identified by the switch number + * which is defined in the heaterSwitches list. + */ + gpioId_t getGpioIdFromSwitchNr(int switchNr); - /** - * @brief Returns the state of a switch (ON - true, or OFF - false). - * @param switchNr The number of the switch to check. - */ - bool checkSwitchState(int switchNr); + /** + * @brief This function runs commands waiting for execution. + */ + void handleActiveCommands(); - /** - * @brief Returns the ID of the GPIO related to a heater identified by the switch number - * which is defined in the heaterSwitches list. - */ - gpioId_t getGpioIdFromSwitchNr(int switchNr); + ReturnValue_t initializeHeaterMap(); - /** - * @brief This function runs commands waiting for execution. - */ - void handleActiveCommands(); + /** + * @brief Sets all switches to OFF. + */ + void setInitialSwitchStates(); - ReturnValue_t initializeHeaterMap(); + void handleSwitchOnCommand(HeaterMapIter heaterMapIter); - /** - * @brief Sets all switches to OFF. - */ - void setInitialSwitchStates(); - - void handleSwitchOnCommand(HeaterMapIter heaterMapIter); - - void handleSwitchOffCommand(HeaterMapIter heaterMapIter); - - /** - * @brief Checks if all switches are off. - * @return True if all switches are off, otherwise false. - */ - bool allSwitchesOff(); + void handleSwitchOffCommand(HeaterMapIter heaterMapIter); + /** + * @brief Checks if all switches are off. + * @return True if all switches are off, otherwise false. + */ + bool allSwitchesOff(); }; #endif /* MISSION_DEVICES_HEATERHANDLER_H_ */ diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index 125040d7..499b4d6e 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -1,248 +1,249 @@ #include "IMTQHandler.h" -#include "OBSWConfig.h" -#include #include +#include #include -IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), engHkDataset(this), calMtmMeasurementSet( - this), rawMtmMeasurementSet(this), posXselfTestDataset(this), negXselfTestDataset( - this), posYselfTestDataset(this), negYselfTestDataset(this), posZselfTestDataset( - this), negZselfTestDataset(this) { - if (comCookie == NULL) { - sif::error << "IMTQHandler: Invalid com cookie" << std::endl; - } +#include "OBSWConfig.h" + +IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), + engHkDataset(this), + calMtmMeasurementSet(this), + rawMtmMeasurementSet(this), + posXselfTestDataset(this), + negXselfTestDataset(this), + posYselfTestDataset(this), + negYselfTestDataset(this), + posZselfTestDataset(this), + negZselfTestDataset(this) { + if (comCookie == NULL) { + sif::error << "IMTQHandler: Invalid com cookie" << std::endl; + } } -IMTQHandler::~IMTQHandler() { -} +IMTQHandler::~IMTQHandler() {} void IMTQHandler::doStartUp() { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } -void IMTQHandler::doShutDown() { - setMode(_MODE_POWER_DOWN); -} +void IMTQHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -ReturnValue_t IMTQHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (communicationStep) { +ReturnValue_t IMTQHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (communicationStep) { case CommunicationStep::GET_ENG_HK_DATA: - *id = IMTQ::GET_ENG_HK_DATA; - communicationStep = CommunicationStep::START_MTM_MEASUREMENT; - break; + *id = IMTQ::GET_ENG_HK_DATA; + communicationStep = CommunicationStep::START_MTM_MEASUREMENT; + break; case CommunicationStep::START_MTM_MEASUREMENT: - *id = IMTQ::START_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_CAL_MTM_MEASUREMENT; - break; + *id = IMTQ::START_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_CAL_MTM_MEASUREMENT; + break; case CommunicationStep::GET_CAL_MTM_MEASUREMENT: - *id = IMTQ::GET_CAL_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_RAW_MTM_MEASUREMENT; - break; + *id = IMTQ::GET_CAL_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_RAW_MTM_MEASUREMENT; + break; case CommunicationStep::GET_RAW_MTM_MEASUREMENT: - *id = IMTQ::GET_RAW_MTM_MEASUREMENT; - communicationStep = CommunicationStep::GET_ENG_HK_DATA; - break; + *id = IMTQ::GET_RAW_MTM_MEASUREMENT; + communicationStep = CommunicationStep::GET_ENG_HK_DATA; + break; default: - sif::debug << "IMTQHandler::buildNormalDeviceCommand: Invalid communication step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "IMTQHandler::buildNormalDeviceCommand: Invalid communication step" + << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t IMTQHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return RETURN_OK; -} +ReturnValue_t IMTQHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { return RETURN_OK; } ReturnValue_t IMTQHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - switch (deviceCommand) { + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { case (IMTQ::POS_X_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_X_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::X_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::POS_Y_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_Y_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Y_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::POS_Z_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_POSITIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_POSITIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::NEG_Z_SELF_TEST): { - commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; - commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_NEGATIVE; - rawPacket = commandBuffer; - rawPacketLen = 2; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::SELF_TEST_CMD; + commandBuffer[1] = IMTQ::SELF_TEST_AXIS::Z_NEGATIVE; + rawPacket = commandBuffer; + rawPacketLen = 2; + return RETURN_OK; } case (IMTQ::GET_SELF_TEST_RESULT): { - commandBuffer[0] = IMTQ::CC::GET_SELF_TEST_RESULT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_SELF_TEST_RESULT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::START_ACTUATION_DIPOLE): { - /* IMTQ expects low byte first */ - commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE; - commandBuffer[1] = *(commandData + 1); - commandBuffer[2] = *(commandData); - commandBuffer[3] = *(commandData + 3); - commandBuffer[4] = *(commandData + 2); - commandBuffer[5] = *(commandData + 5); - commandBuffer[6] = *(commandData + 4); - commandBuffer[7] = *(commandData + 7); - commandBuffer[8] = *(commandData + 6); - rawPacket = commandBuffer; - rawPacketLen = 9; - return RETURN_OK; + /* IMTQ expects low byte first */ + commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE; + commandBuffer[1] = *(commandData + 1); + commandBuffer[2] = *(commandData); + commandBuffer[3] = *(commandData + 3); + commandBuffer[4] = *(commandData + 2); + commandBuffer[5] = *(commandData + 5); + commandBuffer[6] = *(commandData + 4); + commandBuffer[7] = *(commandData + 7); + commandBuffer[8] = *(commandData + 6); + rawPacket = commandBuffer; + rawPacketLen = 9; + return RETURN_OK; } case (IMTQ::GET_ENG_HK_DATA): { - commandBuffer[0] = IMTQ::CC::GET_ENG_HK_DATA; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_ENG_HK_DATA; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_COMMANDED_DIPOLE): { - commandBuffer[0] = IMTQ::CC::GET_COMMANDED_DIPOLE; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_COMMANDED_DIPOLE; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::START_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::START_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::START_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_CAL_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::GET_CAL_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_CAL_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } case (IMTQ::GET_RAW_MTM_MEASUREMENT): { - commandBuffer[0] = IMTQ::CC::GET_RAW_MTM_MEASUREMENT; - rawPacket = commandBuffer; - rawPacketLen = 1; - return RETURN_OK; + commandBuffer[0] = IMTQ::CC::GET_RAW_MTM_MEASUREMENT; + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void IMTQHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(IMTQ::POS_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::POS_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::POS_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::NEG_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_SELF_TEST_RESULT, 1, nullptr, - IMTQ::SIZE_SELF_TEST_RESULTS); - this->insertInCommandAndReplyMap(IMTQ::START_ACTUATION_DIPOLE, 1, nullptr, - IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_ENG_HK_DATA, 1, &engHkDataset, - IMTQ::SIZE_ENG_HK_DATA_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_COMMANDED_DIPOLE, 1, nullptr, - IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY); - this->insertInCommandAndReplyMap(IMTQ::START_MTM_MEASUREMENT, 1, nullptr, - IMTQ::SIZE_STATUS_REPLY); - this->insertInCommandAndReplyMap(IMTQ::GET_CAL_MTM_MEASUREMENT, 1, &calMtmMeasurementSet, - IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT); - this->insertInCommandAndReplyMap(IMTQ::GET_RAW_MTM_MEASUREMENT, 1, &rawMtmMeasurementSet, - IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT); + this->insertInCommandAndReplyMap(IMTQ::POS_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_X_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::POS_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_Y_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::POS_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::NEG_Z_SELF_TEST, 1, nullptr, IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_SELF_TEST_RESULT, 1, nullptr, + IMTQ::SIZE_SELF_TEST_RESULTS); + this->insertInCommandAndReplyMap(IMTQ::START_ACTUATION_DIPOLE, 1, nullptr, + IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_ENG_HK_DATA, 1, &engHkDataset, + IMTQ::SIZE_ENG_HK_DATA_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_COMMANDED_DIPOLE, 1, nullptr, + IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY); + this->insertInCommandAndReplyMap(IMTQ::START_MTM_MEASUREMENT, 1, nullptr, + IMTQ::SIZE_STATUS_REPLY); + this->insertInCommandAndReplyMap(IMTQ::GET_CAL_MTM_MEASUREMENT, 1, &calMtmMeasurementSet, + IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT); + this->insertInCommandAndReplyMap(IMTQ::GET_RAW_MTM_MEASUREMENT, 1, &rawMtmMeasurementSet, + IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT); } -ReturnValue_t IMTQHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t IMTQHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (*start) { + switch (*start) { case (IMTQ::CC::START_ACTUATION_DIPOLE): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - *foundId = IMTQ::START_ACTUATION_DIPOLE; - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + *foundId = IMTQ::START_ACTUATION_DIPOLE; + break; case (IMTQ::CC::START_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - *foundId = IMTQ::START_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + *foundId = IMTQ::START_MTM_MEASUREMENT; + break; case (IMTQ::CC::GET_ENG_HK_DATA): - *foundLen = IMTQ::SIZE_ENG_HK_DATA_REPLY; - *foundId = IMTQ::GET_ENG_HK_DATA; - break; + *foundLen = IMTQ::SIZE_ENG_HK_DATA_REPLY; + *foundId = IMTQ::GET_ENG_HK_DATA; + break; case (IMTQ::CC::GET_COMMANDED_DIPOLE): - *foundLen = IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY; - *foundId = IMTQ::GET_COMMANDED_DIPOLE; - break; + *foundLen = IMTQ::SIZE_GET_COMMANDED_DIPOLE_REPLY; + *foundId = IMTQ::GET_COMMANDED_DIPOLE; + break; case (IMTQ::CC::GET_CAL_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT; - *foundId = IMTQ::GET_CAL_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_GET_CAL_MTM_MEASUREMENT; + *foundId = IMTQ::GET_CAL_MTM_MEASUREMENT; + break; case (IMTQ::CC::GET_RAW_MTM_MEASUREMENT): - *foundLen = IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT; - *foundId = IMTQ::GET_RAW_MTM_MEASUREMENT; - break; + *foundLen = IMTQ::SIZE_GET_RAW_MTM_MEASUREMENT; + *foundId = IMTQ::GET_RAW_MTM_MEASUREMENT; + break; case (IMTQ::CC::SELF_TEST_CMD): - *foundLen = IMTQ::SIZE_STATUS_REPLY; - result = getSelfTestCommandId(foundId); - break; + *foundLen = IMTQ::SIZE_STATUS_REPLY; + result = getSelfTestCommandId(foundId); + break; case (IMTQ::CC::GET_SELF_TEST_RESULT): - *foundLen = IMTQ::SIZE_SELF_TEST_RESULTS; - *foundId = IMTQ::GET_SELF_TEST_RESULT; - break; + *foundLen = IMTQ::SIZE_SELF_TEST_RESULTS; + *foundId = IMTQ::GET_SELF_TEST_RESULT; + break; default: - sif::debug << "IMTQHandler::scanForReply: Reply contains invalid command code" << std::endl; - result = IGNORE_REPLY_DATA; - break; - } + sif::debug << "IMTQHandler::scanForReply: Reply contains invalid command code" << std::endl; + result = IGNORE_REPLY_DATA; + break; + } - return result; + return result; } -ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = parseStatusByte(packet); - result = parseStatusByte(packet); + if (result != RETURN_OK) { + return result; + } - if (result != RETURN_OK) { - return result; - } - - switch (id) { + switch (id) { case (IMTQ::POS_X_SELF_TEST): case (IMTQ::NEG_X_SELF_TEST): case (IMTQ::POS_Y_SELF_TEST): @@ -251,1879 +252,1923 @@ ReturnValue_t IMTQHandler::interpretDeviceReply(DeviceCommandId_t id, const uint case (IMTQ::NEG_Z_SELF_TEST): case (IMTQ::START_ACTUATION_DIPOLE): case (IMTQ::START_MTM_MEASUREMENT): - /* Replies only the status byte which is already handled with parseStatusByte */ - break; + /* Replies only the status byte which is already handled with parseStatusByte */ + break; case (IMTQ::GET_ENG_HK_DATA): - fillEngHkDataset(packet); - break; + fillEngHkDataset(packet); + break; case (IMTQ::GET_COMMANDED_DIPOLE): - handleGetCommandedDipoleReply(packet); - break; + handleGetCommandedDipoleReply(packet); + break; case (IMTQ::GET_CAL_MTM_MEASUREMENT): - fillCalibratedMtmDataset(packet); - break; + fillCalibratedMtmDataset(packet); + break; case (IMTQ::GET_RAW_MTM_MEASUREMENT): - fillRawMtmDataset(packet); - break; + fillRawMtmDataset(packet); + break; case (IMTQ::GET_SELF_TEST_RESULT): - handleSelfTestReply(packet); - break; + handleSelfTestReply(packet); + break; default: { - sif::debug << "IMTQHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "IMTQHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return RETURN_OK; + return RETURN_OK; } -void IMTQHandler::setNormalDatapoolEntriesInvalid() { - -} +void IMTQHandler::setNormalDatapoolEntriesInvalid() {} LocalPoolDataSetBase* IMTQHandler::getDataSetHandle(sid_t sid) { - if (sid == engHkDataset.getSid()) { - return &engHkDataset; - } else if (sid == calMtmMeasurementSet.getSid()) { - return &calMtmMeasurementSet; - } else if (sid == rawMtmMeasurementSet.getSid()) { - return &rawMtmMeasurementSet; - } else if (sid == posXselfTestDataset.getSid()) { - return &posXselfTestDataset; - } else if (sid == negXselfTestDataset.getSid()) { - return &negXselfTestDataset; - } else if (sid == posYselfTestDataset.getSid()) { - return &posYselfTestDataset; - } else if (sid == negYselfTestDataset.getSid()) { - return &negYselfTestDataset; - } else if (sid == posZselfTestDataset.getSid()) { - return &posZselfTestDataset; - } else if (sid == negZselfTestDataset.getSid()) { - return &negZselfTestDataset; - } else { - sif::error << "IMTQHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == engHkDataset.getSid()) { + return &engHkDataset; + } else if (sid == calMtmMeasurementSet.getSid()) { + return &calMtmMeasurementSet; + } else if (sid == rawMtmMeasurementSet.getSid()) { + return &rawMtmMeasurementSet; + } else if (sid == posXselfTestDataset.getSid()) { + return &posXselfTestDataset; + } else if (sid == negXselfTestDataset.getSid()) { + return &negXselfTestDataset; + } else if (sid == posYselfTestDataset.getSid()) { + return &posYselfTestDataset; + } else if (sid == negYselfTestDataset.getSid()) { + return &negYselfTestDataset; + } else if (sid == posZselfTestDataset.getSid()) { + return &posZselfTestDataset; + } else if (sid == negZselfTestDataset.getSid()) { + return &negZselfTestDataset; + } else { + sif::error << "IMTQHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } -uint32_t IMTQHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; -} +uint32_t IMTQHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t IMTQHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + /** Entries of engineering housekeeping dataset */ + localDataPoolMap.emplace(IMTQ::DIGITAL_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ANALOG_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::DIGITAL_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ANALOG_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::COIL_Z_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MCU_TEMPERATURE, new PoolEntry({0})); - /** Entries of engineering housekeeping dataset */ - localDataPoolMap.emplace(IMTQ::DIGITAL_VOLTAGE_MV, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ANALOG_VOLTAGE_MV, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::DIGITAL_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ANALOG_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MCU_TEMPERATURE, new PoolEntry( { 0 })); + /** Entries of calibrated MTM measurement dataset */ + localDataPoolMap.emplace(IMTQ::MTM_CAL_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_CAL_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_CAL_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ACTUATION_CAL_STATUS, new PoolEntry({0})); - /** Entries of calibrated MTM measurement dataset */ - localDataPoolMap.emplace(IMTQ::MTM_CAL_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_CAL_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_CAL_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ACTUATION_CAL_STATUS, new PoolEntry( { 0 })); + /** Entries of raw MTM measurement dataset */ + localDataPoolMap.emplace(IMTQ::MTM_RAW_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_RAW_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::MTM_RAW_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::ACTUATION_RAW_STATUS, new PoolEntry({0})); - /** Entries of raw MTM measurement dataset */ - localDataPoolMap.emplace(IMTQ::MTM_RAW_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_RAW_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::MTM_RAW_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::ACTUATION_RAW_STATUS, new PoolEntry( { 0 })); + /** INIT measurements for positive X axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive X axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative X axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative X axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for positive Y axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive Y axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative Y axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative Y axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for positive Z axis test */ + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for positive Z axis test */ - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** INIT measurements for negative Z axis test */ + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** INIT measurements for negative Z axis test */ - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::INIT_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(IMTQ::NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(IMTQ::NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive X axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive X axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative X axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative X axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_X_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive Y axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive Y axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative Y axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative Y axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Y_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for positive Z axis test */ + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for positive Z axis test */ - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_POS_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); + /** FINA measurements for negative Z axis test */ + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_ERR, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_X, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Y, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Z, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); - /** FINA measurements for negative Z axis test */ - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_ERR, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_RAW_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_X, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Y, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_CAL_MAG_Z, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_X_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t IMTQHandler::getSelfTestCommandId(DeviceCommandId_t* id) { - DeviceCommandId_t commandId = getPendingCommand(); - switch (commandId) { + DeviceCommandId_t commandId = getPendingCommand(); + switch (commandId) { case IMTQ::POS_X_SELF_TEST: case IMTQ::NEG_X_SELF_TEST: case IMTQ::POS_Y_SELF_TEST: case IMTQ::NEG_Y_SELF_TEST: case IMTQ::POS_Z_SELF_TEST: case IMTQ::NEG_Z_SELF_TEST: - *id = commandId; - break; + *id = commandId; + break; default: - sif::error << "IMTQHandler::getSelfTestCommandId: Reply does not match to pending " - << "command" << std::endl; - return UNEXPECTED_SELF_TEST_REPLY; - } - return RETURN_OK; + sif::error << "IMTQHandler::getSelfTestCommandId: Reply does not match to pending " + << "command" << std::endl; + return UNEXPECTED_SELF_TEST_REPLY; + } + return RETURN_OK; } ReturnValue_t IMTQHandler::parseStatusByte(const uint8_t* packet) { - uint8_t cmdErrorField = *(packet + 1) & 0xF; - switch (cmdErrorField) { + uint8_t cmdErrorField = *(packet + 1) & 0xF; + switch (cmdErrorField) { case 0: - return RETURN_OK; + return RETURN_OK; case 1: - sif::error << "IMTQHandler::parseStatusByte: Command rejected without reason" << std::endl; - return REJECTED_WITHOUT_REASON; + sif::error << "IMTQHandler::parseStatusByte: Command rejected without reason" << std::endl; + return REJECTED_WITHOUT_REASON; case 2: - sif::error << "IMTQHandler::parseStatusByte: Command has invalid command code" << std::endl; - return INVALID_COMMAND_CODE; + sif::error << "IMTQHandler::parseStatusByte: Command has invalid command code" << std::endl; + return INVALID_COMMAND_CODE; case 3: - sif::error << "IMTQHandler::parseStatusByte: Command has missing parameter" << std::endl; - return PARAMETER_MISSING; + sif::error << "IMTQHandler::parseStatusByte: Command has missing parameter" << std::endl; + return PARAMETER_MISSING; case 4: - sif::error << "IMTQHandler::parseStatusByte: Command has invalid parameter" << std::endl; - return PARAMETER_INVALID; + sif::error << "IMTQHandler::parseStatusByte: Command has invalid parameter" << std::endl; + return PARAMETER_INVALID; case 5: - sif::error << "IMTQHandler::parseStatusByte: CC unavailable" << std::endl; - return CC_UNAVAILABLE; + sif::error << "IMTQHandler::parseStatusByte: CC unavailable" << std::endl; + return CC_UNAVAILABLE; case 7: - sif::error << "IMTQHandler::parseStatusByte: IMQT replied internal processing error" - << std::endl; - return INTERNAL_PROCESSING_ERROR; + sif::error << "IMTQHandler::parseStatusByte: IMQT replied internal processing error" + << std::endl; + return INTERNAL_PROCESSING_ERROR; default: - sif::error << "IMTQHandler::parseStatusByte: CMD Error field contains unknown error code " - << cmdErrorField << std::endl; - return CMD_ERR_UNKNOWN; - } + sif::error << "IMTQHandler::parseStatusByte: CMD Error field contains unknown error code " + << cmdErrorField << std::endl; + return CMD_ERR_UNKNOWN; + } } void IMTQHandler::fillEngHkDataset(const uint8_t* packet) { - PoolReadGuard rg(&engHkDataset); - uint8_t offset = 2; - engHkDataset.digitalVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - engHkDataset.analogVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - engHkDataset.digitalCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.analogCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilXCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilYCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilZCurrentmA = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - engHkDataset.coilXTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.coilYTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.coilZTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); - offset += 2; - engHkDataset.mcuTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + PoolReadGuard rg(&engHkDataset); + uint8_t offset = 2; + engHkDataset.digitalVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + engHkDataset.analogVoltageMv = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + engHkDataset.digitalCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.analogCurrentmA = (*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilXCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilYCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilZCurrentmA = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + engHkDataset.coilXTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.coilYTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.coilZTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); + offset += 2; + engHkDataset.mcuTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ digital voltage: " << engHkDataset.digitalVoltageMv << " mV" << std::endl; - sif::info << "IMTQ analog voltage: " << engHkDataset.analogVoltageMv << " mV" << std::endl; - sif::info << "IMTQ digital current: " << engHkDataset.digitalCurrentmA << " mA" << std::endl; - sif::info << "IMTQ analog current: " << engHkDataset.analogCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil X current: " << engHkDataset.coilXCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil Y current: " << engHkDataset.coilYCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil Z current: " << engHkDataset.coilZCurrentmA << " mA" << std::endl; - sif::info << "IMTQ coil X temperature: " << engHkDataset.coilXTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil Y temperature: " << engHkDataset.coilYTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil Z temperature: " << engHkDataset.coilZTemperature << " °C" - << std::endl; - sif::info << "IMTQ coil MCU temperature: " << engHkDataset.mcuTemperature << " °C" - << std::endl; +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ digital voltage: " << engHkDataset.digitalVoltageMv << " mV" << std::endl; + sif::info << "IMTQ analog voltage: " << engHkDataset.analogVoltageMv << " mV" << std::endl; + sif::info << "IMTQ digital current: " << engHkDataset.digitalCurrentmA << " mA" << std::endl; + sif::info << "IMTQ analog current: " << engHkDataset.analogCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil X current: " << engHkDataset.coilXCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil Y current: " << engHkDataset.coilYCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil Z current: " << engHkDataset.coilZCurrentmA << " mA" << std::endl; + sif::info << "IMTQ coil X temperature: " << engHkDataset.coilXTemperature << " °C" << std::endl; + sif::info << "IMTQ coil Y temperature: " << engHkDataset.coilYTemperature << " °C" << std::endl; + sif::info << "IMTQ coil Z temperature: " << engHkDataset.coilZTemperature << " °C" << std::endl; + sif::info << "IMTQ coil MCU temperature: " << engHkDataset.mcuTemperature << " °C" << std::endl; #endif } -void IMTQHandler::setModeNormal() { - mode = MODE_NORMAL; -} +void IMTQHandler::setModeNormal() { mode = MODE_NORMAL; } void IMTQHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "IMTQHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "IMTQHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - ReturnValue_t result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "IMTQHandler::handleDeviceTM: Failed to report data" << std::endl; - return; - } + ReturnValue_t result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "IMTQHandler::handleDeviceTM: Failed to report data" << std::endl; + return; + } } void IMTQHandler::handleGetCommandedDipoleReply(const uint8_t* packet) { - uint8_t tmData[6]; - /* Switching endianess of received dipole values */ - tmData[0] = *(packet + 3); - tmData[1] = *(packet + 2); - tmData[2] = *(packet + 5); - tmData[3] = *(packet + 4); - tmData[4] = *(packet + 7); - tmData[5] = *(packet + 6); - handleDeviceTM(tmData, sizeof(tmData), IMTQ::GET_COMMANDED_DIPOLE); + uint8_t tmData[6]; + /* Switching endianess of received dipole values */ + tmData[0] = *(packet + 3); + tmData[1] = *(packet + 2); + tmData[2] = *(packet + 5); + tmData[3] = *(packet + 4); + tmData[4] = *(packet + 7); + tmData[5] = *(packet + 6); + handleDeviceTM(tmData, sizeof(tmData), IMTQ::GET_COMMANDED_DIPOLE); } void IMTQHandler::fillCalibratedMtmDataset(const uint8_t* packet) { - PoolReadGuard rg(&calMtmMeasurementSet); - int8_t offset = 2; - calMtmMeasurementSet.mtmXnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.mtmYnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.mtmZnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - calMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) - | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ calibrated MTM measurement X: " << calMtmMeasurementSet.mtmXnT << " nT" + PoolReadGuard rg(&calMtmMeasurementSet); + int8_t offset = 2; + calMtmMeasurementSet.mtmXnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.mtmYnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.mtmZnT = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + calMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | + (*(packet + offset + 2) << 16) | + (*(packet + offset + 1) << 8) | (*(packet + offset)); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ calibrated MTM measurement X: " << calMtmMeasurementSet.mtmXnT << " nT" << std::endl; - sif::info << "IMTQ calibrated MTM measurement Y: " << calMtmMeasurementSet.mtmYnT << " nT" + sif::info << "IMTQ calibrated MTM measurement Y: " << calMtmMeasurementSet.mtmYnT << " nT" << std::endl; - sif::info << "IMTQ calibrated MTM measurement Z: " << calMtmMeasurementSet.mtmZnT << " nT" + sif::info << "IMTQ calibrated MTM measurement Z: " << calMtmMeasurementSet.mtmZnT << " nT" << std::endl; - sif::info << "IMTQ coil actuation status during MTM measurement: " - << (unsigned int) calMtmMeasurementSet.coilActuationStatus.value << std::endl; + sif::info << "IMTQ coil actuation status during MTM measurement: " + << (unsigned int)calMtmMeasurementSet.coilActuationStatus.value << std::endl; #endif } void IMTQHandler::fillRawMtmDataset(const uint8_t* packet) { - PoolReadGuard rg(&rawMtmMeasurementSet); - int8_t offset = 2; - rawMtmMeasurementSet.mtmXnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.mtmYnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.mtmZnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - rawMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) - | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ raw MTM measurement X: " << rawMtmMeasurementSet.mtmXnT << " nT" - << std::endl; - sif::info << "IMTQ raw MTM measurement Y: " << rawMtmMeasurementSet.mtmYnT << " nT" - << std::endl; - sif::info << "IMTQ raw MTM measurement Z: " << rawMtmMeasurementSet.mtmZnT << " nT" - << std::endl; - sif::info << "IMTQ coil actuation status during MTM measurement: " - << (unsigned int) rawMtmMeasurementSet.coilActuationStatus.value << std::endl; + PoolReadGuard rg(&rawMtmMeasurementSet); + int8_t offset = 2; + rawMtmMeasurementSet.mtmXnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.mtmYnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.mtmZnT = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + rawMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | + (*(packet + offset + 2) << 16) | + (*(packet + offset + 1) << 8) | (*(packet + offset)); +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ raw MTM measurement X: " << rawMtmMeasurementSet.mtmXnT << " nT" << std::endl; + sif::info << "IMTQ raw MTM measurement Y: " << rawMtmMeasurementSet.mtmYnT << " nT" << std::endl; + sif::info << "IMTQ raw MTM measurement Z: " << rawMtmMeasurementSet.mtmZnT << " nT" << std::endl; + sif::info << "IMTQ coil actuation status during MTM measurement: " + << (unsigned int)rawMtmMeasurementSet.coilActuationStatus.value << std::endl; #endif } void IMTQHandler::handleSelfTestReply(const uint8_t* packet) { - uint16_t offset = 2; - checkErrorByte(*(packet + offset), *(packet + offset + 1)); + uint16_t offset = 2; + checkErrorByte(*(packet + offset), *(packet + offset + 1)); - switch (*(packet + IMTQ::MAIN_STEP_OFFSET)) { + switch (*(packet + IMTQ::MAIN_STEP_OFFSET)) { case IMTQ::SELF_TEST_STEPS::X_POSITIVE: { - handlePositiveXSelfTestReply(packet); - break; + handlePositiveXSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::X_NEGATIVE: { - handleNegativeXSelfTestReply(packet); - break; + handleNegativeXSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Y_POSITIVE: { - handlePositiveYSelfTestReply(packet); - break; + handlePositiveYSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Y_NEGATIVE: { - handleNegativeYSelfTestReply(packet); - break; + handleNegativeYSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Z_POSITIVE: { - handlePositiveZSelfTestReply(packet); - break; + handlePositiveZSelfTestReply(packet); + break; } case IMTQ::SELF_TEST_STEPS::Z_NEGATIVE: { - handleNegativeZSelfTestReply(packet); - break; + handleNegativeZSelfTestReply(packet); + break; } default: - break; - } + break; + } } void IMTQHandler::handlePositiveXSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posXselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posXselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posXselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posXselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posXselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posXselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posXselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posXselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posXselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posXselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posXselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posXselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posXselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posXselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posXselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posXselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posXselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posXselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posXselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posXselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posXselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posXselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posXselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posXselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posXselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posXselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posXselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) err: " + sif::info << "IMTQ self test (+X) err: " << static_cast(posXselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field X: " << posXselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field Y: " << posXselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) raw magnetic field Z: " << posXselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field X: " << posXselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field Y: " << posXselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) calibrated magnetic field Z: " << posXselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil X current: " << posXselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field X: " << posXselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil Y current: " << posXselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field Y: " << posXselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil Z current: " << posXselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+X) raw magnetic field Z: " << posXselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+X) coil X temperature: " << posXselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+X) calibrated magnetic field X: " << posXselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) calibrated magnetic field Y: " << posXselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) calibrated magnetic field Z: " << posXselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+X) coil X current: " << posXselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil Y current: " << posXselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil Z current: " << posXselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+X) coil X temperature: " << posXselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) coil Y temperature: " << posXselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+X) coil Y temperature: " << posXselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+X) coil Z temperature: " << posXselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+X) coil Z temperature: " << posXselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posXselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posXselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posXselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posXselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posXselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posXselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posXselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posXselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posXselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posXselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posXselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posXselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posXselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posXselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posXselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posXselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posXselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posXselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posXselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeXSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - negXselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + negXselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negXselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negXselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negXselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negXselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negXselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negXselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negXselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negXselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negXselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negXselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negXselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negXselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negXselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negXselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negXselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negXselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negXselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negXselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negXselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negXselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negXselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negXselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negXselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negXselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negXselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negXselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negXselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negXselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) err: " + sif::info << "IMTQ self test (-X) err: " << static_cast(negXselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field X: " << negXselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field Y: " << negXselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) raw magnetic field Z: " << negXselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field X: " << negXselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field Y: " << negXselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) calibrated magnetic field Z: " << negXselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil X current: " << negXselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field X: " << negXselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil Y current: " << negXselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field Y: " << negXselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil Z current: " << negXselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-X) raw magnetic field Z: " << negXselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-X) coil X temperature: " << negXselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-X) calibrated magnetic field X: " << negXselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) calibrated magnetic field Y: " << negXselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) calibrated magnetic field Z: " << negXselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-X) coil X current: " << negXselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil Y current: " << negXselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil Z current: " << negXselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-X) coil X temperature: " << negXselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) coil Y temperature: " << negXselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-X) coil Y temperature: " << negXselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-X) coil Z temperature: " << negXselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-X) coil Z temperature: " << negXselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negXselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negXselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negXselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negXselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negXselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negXselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negXselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negXselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negXselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negXselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negXselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negXselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negXselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negXselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negXselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negXselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negXselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negXselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negXselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handlePositiveYSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posYselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posYselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posYselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posYselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posYselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posYselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posYselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posYselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posYselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posYselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posYselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posYselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posYselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posYselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posYselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posYselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posYselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posYselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posYselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posYselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posYselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posYselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posYselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posYselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posYselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posYselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posYselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) err: " + sif::info << "IMTQ self test (+Y) err: " << static_cast(posYselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field X: " << posYselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field Y: " << posYselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) raw magnetic field Z: " << posYselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field X: " << posYselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field Y: " << posYselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) calibrated magnetic field Z: " << posYselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil X current: " << posYselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field X: " << posYselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil Y current: " << posYselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field Y: " << posYselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil Z current: " << posYselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+Y) raw magnetic field Z: " << posYselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+Y) coil X temperature: " << posYselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+Y) calibrated magnetic field X: " << posYselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) calibrated magnetic field Y: " << posYselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) calibrated magnetic field Z: " << posYselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+Y) coil X current: " << posYselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil Y current: " << posYselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil Z current: " << posYselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Y) coil X temperature: " << posYselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) coil Y temperature: " << posYselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+Y) coil Y temperature: " << posYselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Y) coil Z temperature: " << posYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+Y) coil Z temperature: " << posYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posYselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posYselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posYselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posYselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posYselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posYselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posYselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posYselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posYselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posYselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posYselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posYselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posYselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posYselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posYselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posYselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posYselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posYselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posYselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeYSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negYselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negYselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negYselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negYselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negYselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negYselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negYselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negYselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negYselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negYselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negYselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negYselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negYselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negYselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negYselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negYselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negYselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negYselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negYselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negYselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negYselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negYselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negYselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negYselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negYselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negYselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negYselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negYselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) err: " + sif::info << "IMTQ self test (-Y) err: " << static_cast(negYselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field X: " << negYselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field Y: " << negYselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) raw magnetic field Z: " << negYselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field X: " << negYselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field Y: " << negYselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) calibrated magnetic field Z: " << negYselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil X current: " << negYselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field X: " << negYselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil Y current: " << negYselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field Y: " << negYselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil Z current: " << negYselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-Y) raw magnetic field Z: " << negYselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-Y) coil X temperature: " << negYselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-Y) calibrated magnetic field X: " << negYselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) calibrated magnetic field Y: " << negYselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) calibrated magnetic field Z: " << negYselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-Y) coil X current: " << negYselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil Y current: " << negYselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil Z current: " << negYselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Y) coil X temperature: " << negYselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) coil Y temperature: " << negYselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-Y) coil Y temperature: " << negYselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Y) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-Y) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negYselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negYselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negYselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negYselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negYselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negYselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negYselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negYselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negYselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negYselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negYselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negYselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negYselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negYselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negYselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negYselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negYselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negYselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negYselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handlePositiveZSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - posZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + posZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posZselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posZselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - posZselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - posZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - posZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - posZselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - posZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - posZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + posZselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + posZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + posZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + posZselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + posZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + posZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(posZselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posZselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posZselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posZselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << posZselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posZselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << posZselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << posZselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << posZselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << posZselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << posZselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << posZselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << posZselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << posZselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << posZselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << posZselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << posZselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << posZselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << posZselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) err: " + sif::info << "IMTQ self test (+Z) err: " << static_cast(posZselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field X: " << posZselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field Y: " << posZselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) raw magnetic field Z: " << posZselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field X: " << posZselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field Y: " << posZselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) calibrated magnetic field Z: " << posZselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil X current: " << posZselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field X: " << posZselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil Y current: " << posZselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field Y: " << posZselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil Z current: " << posZselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (+Z) raw magnetic field Z: " << posZselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (+Z) coil X temperature: " << posZselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (+Z) calibrated magnetic field X: " << posZselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) calibrated magnetic field Y: " << posZselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) calibrated magnetic field Z: " << posZselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (+Z) coil X current: " << posZselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil Y current: " << posZselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil Z current: " << posZselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (+Z) coil X temperature: " << posZselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) coil Y temperature: " << posZselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (+Z) coil Y temperature: " << posZselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (+Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (+Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(posZselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posZselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << posZselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posZselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << posZselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posZselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << posZselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << posZselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << posZselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << posZselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << posZselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << posZselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << posZselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << posZselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << posZselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << posZselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << posZselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << posZselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << posZselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::handleNegativeZSelfTestReply(const uint8_t* packet) { - PoolReadGuard rg(&posXselfTestDataset); + PoolReadGuard rg(&posXselfTestDataset); - uint16_t offset = 2; - /** Init measurements */ - negZselfTestDataset.initErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.initCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + uint16_t offset = 2; + /** Init measurements */ + negZselfTestDataset.initErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.initRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.initCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.initCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.initCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.initCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.initCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** +X measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negZselfTestDataset.err = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.coilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** +X measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negZselfTestDataset.err = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.rawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.rawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.rawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.calMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.calMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.calMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.coilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.coilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.coilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.coilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; - /** FINA measurements */ - checkErrorByte(*(packet + offset), *(packet + offset + 1)); - negZselfTestDataset.finaErr = *(packet + offset); - offset += 2; // STEP byte will not be stored - negZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset)) * 7.5; - offset += 4; - negZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - negZselfTestDataset.finaCoilXCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilYCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilZCurrent = static_cast(*(packet + offset + 1) << 8 - | *(packet + offset)) * 0.1; - offset += 2; - negZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 2; - negZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; + /** FINA measurements */ + checkErrorByte(*(packet + offset), *(packet + offset + 1)); + negZselfTestDataset.finaErr = *(packet + offset); + offset += 2; // STEP byte will not be stored + negZselfTestDataset.finaRawMagX = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaRawMagY = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaRawMagZ = (*(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset)) * + 7.5; + offset += 4; + negZselfTestDataset.finaCalMagX = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCalMagY = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCalMagZ = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + negZselfTestDataset.finaCoilXCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilYCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilZCurrent = + static_cast(*(packet + offset + 1) << 8 | *(packet + offset)) * 0.1; + offset += 2; + negZselfTestDataset.finaCoilXTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.finaCoilYTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 2; + negZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 - sif::info << "IMTQ self test (INIT) err: " +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 + sif::info << "IMTQ self test (INIT) err: " << static_cast(negZselfTestDataset.initErr.value) << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negZselfTestDataset.initRawMagX + sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negZselfTestDataset.initRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negZselfTestDataset.initRawMagY + sif::info << "IMTQ self test (INIT) raw magnetic field Y: " << negZselfTestDataset.initRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negZselfTestDataset.initRawMagZ + sif::info << "IMTQ self test (INIT) raw magnetic field Z: " << negZselfTestDataset.initRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field X: " << negZselfTestDataset.initCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Y: " << negZselfTestDataset.initCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " + sif::info << "IMTQ self test (INIT) calibrated magnetic field Z: " << negZselfTestDataset.initCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (INIT) coil X current: " << negZselfTestDataset.initCoilXCurrent + sif::info << "IMTQ self test (INIT) coil X current: " << negZselfTestDataset.initCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y current: " << negZselfTestDataset.initCoilYCurrent + sif::info << "IMTQ self test (INIT) coil Y current: " << negZselfTestDataset.initCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z current: " << negZselfTestDataset.initCoilZCurrent + sif::info << "IMTQ self test (INIT) coil Z current: " << negZselfTestDataset.initCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (INIT) coil X temperature: " + sif::info << "IMTQ self test (INIT) coil X temperature: " << negZselfTestDataset.initCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Y temperature: " + sif::info << "IMTQ self test (INIT) coil Y temperature: " << negZselfTestDataset.initCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (INIT) coil Z temperature: " + sif::info << "IMTQ self test (INIT) coil Z temperature: " << negZselfTestDataset.initCoilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) err: " + sif::info << "IMTQ self test (-Z) err: " << static_cast(negZselfTestDataset.err.value) << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field X: " << negZselfTestDataset.rawMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field Y: " << negZselfTestDataset.rawMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) raw magnetic field Z: " << negZselfTestDataset.rawMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field X: " << negZselfTestDataset.calMagX - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field Y: " << negZselfTestDataset.calMagY - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) calibrated magnetic field Z: " << negZselfTestDataset.calMagZ - << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil X current: " << negZselfTestDataset.coilXCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field X: " << negZselfTestDataset.rawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil Y current: " << negZselfTestDataset.coilYCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field Y: " << negZselfTestDataset.rawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil Z current: " << negZselfTestDataset.coilZCurrent << " mA" + sif::info << "IMTQ self test (-Z) raw magnetic field Z: " << negZselfTestDataset.rawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (-Z) coil X temperature: " << negZselfTestDataset.coilXTemperature + sif::info << "IMTQ self test (-Z) calibrated magnetic field X: " << negZselfTestDataset.calMagX + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) calibrated magnetic field Y: " << negZselfTestDataset.calMagY + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) calibrated magnetic field Z: " << negZselfTestDataset.calMagZ + << " nT" << std::endl; + sif::info << "IMTQ self test (-Z) coil X current: " << negZselfTestDataset.coilXCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil Y current: " << negZselfTestDataset.coilYCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil Z current: " << negZselfTestDataset.coilZCurrent << " mA" + << std::endl; + sif::info << "IMTQ self test (-Z) coil X temperature: " << negZselfTestDataset.coilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) coil Y temperature: " << negZselfTestDataset.coilYTemperature + sif::info << "IMTQ self test (-Z) coil Y temperature: " << negZselfTestDataset.coilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (-Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature + sif::info << "IMTQ self test (-Z) coil Z temperature: " << negYselfTestDataset.coilZTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) err: " + sif::info << "IMTQ self test (FINA) err: " << static_cast(negZselfTestDataset.finaErr.value) << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negZselfTestDataset.finaRawMagX + sif::info << "IMTQ self test (FINA) raw magnetic field X: " << negZselfTestDataset.finaRawMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negZselfTestDataset.finaRawMagY + sif::info << "IMTQ self test (FINA) raw magnetic field Y: " << negZselfTestDataset.finaRawMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negZselfTestDataset.finaRawMagZ + sif::info << "IMTQ self test (FINA) raw magnetic field Z: " << negZselfTestDataset.finaRawMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field X: " << negZselfTestDataset.finaCalMagX << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Y: " << negZselfTestDataset.finaCalMagY << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " + sif::info << "IMTQ self test (FINA) calibrated magnetic field Z: " << negZselfTestDataset.finaCalMagZ << " nT" << std::endl; - sif::info << "IMTQ self test (FINA) coil X current: " << negZselfTestDataset.finaCoilXCurrent + sif::info << "IMTQ self test (FINA) coil X current: " << negZselfTestDataset.finaCoilXCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y current: " << negZselfTestDataset.finaCoilYCurrent + sif::info << "IMTQ self test (FINA) coil Y current: " << negZselfTestDataset.finaCoilYCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z current: " << negZselfTestDataset.finaCoilZCurrent + sif::info << "IMTQ self test (FINA) coil Z current: " << negZselfTestDataset.finaCoilZCurrent << " mA" << std::endl; - sif::info << "IMTQ self test (FINA) coil X temperature: " + sif::info << "IMTQ self test (FINA) coil X temperature: " << negZselfTestDataset.finaCoilXTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Y temperature: " + sif::info << "IMTQ self test (FINA) coil Y temperature: " << negZselfTestDataset.finaCoilYTemperature << " °C" << std::endl; - sif::info << "IMTQ self test (FINA) coil Z temperature: " + sif::info << "IMTQ self test (FINA) coil Z temperature: " << negZselfTestDataset.finaCoilZTemperature << " °C" << std::endl; #endif } void IMTQHandler::checkErrorByte(const uint8_t errorByte, const uint8_t step) { - std::string stepString(""); - if (step < 8) { - stepString = makeStepString(step); - } else { - /** This should normally never happen */ - sif::debug << "IMTQHandler::checkErrorByte: Invalid step" << std::endl; - return; - } + std::string stepString(""); + if (step < 8) { + stepString = makeStepString(step); + } else { + /** This should normally never happen */ + sif::debug << "IMTQHandler::checkErrorByte: Invalid step" << std::endl; + return; + } - if (errorByte == 0) { - return; - } + if (errorByte == 0) { + return; + } - if (errorByte & IMTQ::I2C_FAILURE_MASK) { - triggerEvent(SELF_TEST_I2C_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test I2C failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::SPI_FAILURE_MASK) { - triggerEvent(SELF_TEST_SPI_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test SPI failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::ADC_FAILURE_MASK) { - triggerEvent(SELF_TEST_ADC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test ADC failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::PWM_FAILURE_MASK) { - triggerEvent(SELF_TEST_PWM_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test PWM failure for step " << stepString - << std::endl; - } - if (errorByte & IMTQ::TC_FAILURE_MASK) { - triggerEvent(SELF_TEST_TC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test TC failure (system failure) for step " - << stepString << std::endl; - } - if (errorByte & IMTQ::MTM_RANGE_FAILURE_MASK) { - triggerEvent(SELF_TEST_TC_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test MTM range failure for step " - << stepString << std::endl; - } - if (errorByte & IMTQ::COIL_CURRENT_FAILURE_MASK) { - triggerEvent(SELF_TEST_COIL_CURRENT_FAILURE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test coil current outside of expected " - "range for step " << stepString << std::endl; - } + if (errorByte & IMTQ::I2C_FAILURE_MASK) { + triggerEvent(SELF_TEST_I2C_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test I2C failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::SPI_FAILURE_MASK) { + triggerEvent(SELF_TEST_SPI_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test SPI failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::ADC_FAILURE_MASK) { + triggerEvent(SELF_TEST_ADC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test ADC failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::PWM_FAILURE_MASK) { + triggerEvent(SELF_TEST_PWM_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test PWM failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::TC_FAILURE_MASK) { + triggerEvent(SELF_TEST_TC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test TC failure (system failure) for step " + << stepString << std::endl; + } + if (errorByte & IMTQ::MTM_RANGE_FAILURE_MASK) { + triggerEvent(SELF_TEST_TC_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test MTM range failure for step " << stepString + << std::endl; + } + if (errorByte & IMTQ::COIL_CURRENT_FAILURE_MASK) { + triggerEvent(SELF_TEST_COIL_CURRENT_FAILURE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test coil current outside of expected " + "range for step " + << stepString << std::endl; + } - if (errorByte & IMTQ::INVALID_ERROR_BYTE) { - triggerEvent(INVALID_ERROR_BYTE, step); - sif::error << "IMTQHandler::checkErrorByte: Self test result of step " << stepString - << " has invalid error byte" << std::endl; - } + if (errorByte & IMTQ::INVALID_ERROR_BYTE) { + triggerEvent(INVALID_ERROR_BYTE, step); + sif::error << "IMTQHandler::checkErrorByte: Self test result of step " << stepString + << " has invalid error byte" << std::endl; + } } std::string IMTQHandler::makeStepString(const uint8_t step) { - std::string stepString(""); - switch (step) { + std::string stepString(""); + switch (step) { case IMTQ::SELF_TEST_STEPS::INIT: - stepString = std::string("INIT"); - break; + stepString = std::string("INIT"); + break; case IMTQ::SELF_TEST_STEPS::X_POSITIVE: - stepString = std::string("+X"); - break; + stepString = std::string("+X"); + break; case IMTQ::SELF_TEST_STEPS::X_NEGATIVE: - stepString = std::string("-X"); - break; + stepString = std::string("-X"); + break; case IMTQ::SELF_TEST_STEPS::Y_POSITIVE: - stepString = std::string("+Y"); - break; + stepString = std::string("+Y"); + break; case IMTQ::SELF_TEST_STEPS::Y_NEGATIVE: - stepString = std::string("-Y"); - break; + stepString = std::string("-Y"); + break; case IMTQ::SELF_TEST_STEPS::Z_POSITIVE: - stepString = std::string("+Z"); - break; + stepString = std::string("+Z"); + break; case IMTQ::SELF_TEST_STEPS::Z_NEGATIVE: - stepString = std::string("-Z"); - break; + stepString = std::string("-Z"); + break; case IMTQ::SELF_TEST_STEPS::FINA: - stepString = std::string("FINA"); - break; + stepString = std::string("FINA"); + break; default: - sif::error << "IMTQHandler::checkErrorByte: Received packet with invalid step information" - << std::endl; - break; - } - return stepString; + sif::error << "IMTQHandler::checkErrorByte: Received packet with invalid step information" + << std::endl; + break; + } + return stepString; } - diff --git a/mission/devices/IMTQHandler.h b/mission/devices/IMTQHandler.h index ce9e45e0..b12cdf97 100644 --- a/mission/devices/IMTQHandler.h +++ b/mission/devices/IMTQHandler.h @@ -10,186 +10,188 @@ * * @author J. Meier */ -class IMTQHandler: public DeviceHandlerBase { -public: +class IMTQHandler : public DeviceHandlerBase { + public: + IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~IMTQHandler(); - IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~IMTQHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + protected: + void doStartUp() override; + void doShutDown() override; + 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; + void setNormalDatapoolEntriesInvalid() override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: - void doStartUp() override; - void doShutDown() override; - 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; - void setNormalDatapoolEntriesInvalid() override; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER; -private: + static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test + //! command has been sent. This should normally never happen. + static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7); - static const uint8_t INTERFACE_ID = CLASS_ID::IMTQ_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER; - static const ReturnValue_t INVALID_COMMAND_CODE = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t PARAMETER_MISSING = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t PARAMETER_INVALID = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t CC_UNAVAILABLE = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t INTERNAL_PROCESSING_ERROR = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t REJECTED_WITHOUT_REASON = MAKE_RETURN_CODE(0xA5); - static const ReturnValue_t CMD_ERR_UNKNOWN = MAKE_RETURN_CODE(0xA6); - //! [EXPORT] : [COMMENT] The status reply to a self test command was received but no self test command has been sent. This should normally never happen. - static const ReturnValue_t UNEXPECTED_SELF_TEST_REPLY = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Get self test result returns I2C failure + //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> + //! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM + //! connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 + //! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and + //! temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 + //! -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil + //! actuation. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> + //! +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure) + //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> + //! -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the + //! expected range. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, + //! 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW); + //! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was + //! outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 + //! -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA + static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW); + //! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication + //! link between IMTQ and OBC. + static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::IMTQ_HANDLER; + IMTQ::EngHkDataset engHkDataset; + IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet; + IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet; + IMTQ::PosXSelfTestSet posXselfTestDataset; + IMTQ::NegXSelfTestSet negXselfTestDataset; + IMTQ::PosYSelfTestSet posYselfTestDataset; + IMTQ::NegYSelfTestSet negYselfTestDataset; + IMTQ::PosZSelfTestSet posZselfTestDataset; + IMTQ::NegZSelfTestSet negZselfTestDataset; - //! [EXPORT] : [COMMENT] Get self test result returns I2C failure - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_I2C_FAILURE = MAKE_EVENT(1, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns SPI failure. This concerns the MTM connectivity. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_SPI_FAILURE = MAKE_EVENT(2, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure in measurement of current and temperature. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_ADC_FAILURE = MAKE_EVENT(3, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns PWM failure which concerns the coil actuation. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_PWM_FAILURE = MAKE_EVENT(4, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns TC failure (system failure) - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_TC_FAILURE = MAKE_EVENT(5, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure that MTM values were outside of the expected range. - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_MTM_RANGE_FAILURE = MAKE_EVENT(6, severity::LOW); - //! [EXPORT] : [COMMENT] Get self test result returns failure indicating that the coil current was outside of the expected range - //! P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA - static const Event SELF_TEST_COIL_CURRENT_FAILURE = MAKE_EVENT(7, severity::LOW); - //! [EXPORT] : [COMMENT] Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC. - static const Event INVALID_ERROR_BYTE = MAKE_EVENT(8, severity::LOW); + uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE]; - IMTQ::EngHkDataset engHkDataset; - IMTQ::CalibratedMtmMeasurementSet calMtmMeasurementSet; - IMTQ::RawMtmMeasurementSet rawMtmMeasurementSet; - IMTQ::PosXSelfTestSet posXselfTestDataset; - IMTQ::NegXSelfTestSet negXselfTestDataset; - IMTQ::PosYSelfTestSet posYselfTestDataset; - IMTQ::NegYSelfTestSet negYselfTestDataset; - IMTQ::PosZSelfTestSet posZselfTestDataset; - IMTQ::NegZSelfTestSet negZselfTestDataset; + enum class CommunicationStep { + GET_ENG_HK_DATA, + START_MTM_MEASUREMENT, + GET_CAL_MTM_MEASUREMENT, + GET_RAW_MTM_MEASUREMENT + }; - uint8_t commandBuffer[IMTQ::MAX_COMMAND_SIZE]; + CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA; - enum class CommunicationStep { - GET_ENG_HK_DATA, - START_MTM_MEASUREMENT, - GET_CAL_MTM_MEASUREMENT, - GET_RAW_MTM_MEASUREMENT - }; + enum class StartupStep { NONE, COMMAND_SELF_TEST, GET_SELF_TEST_RESULT }; - CommunicationStep communicationStep = CommunicationStep::GET_ENG_HK_DATA; + StartupStep startupStep = StartupStep::COMMAND_SELF_TEST; - enum class StartupStep { - NONE, - COMMAND_SELF_TEST, - GET_SELF_TEST_RESULT - }; + bool selfTestPerformed = false; - StartupStep startupStep = StartupStep::COMMAND_SELF_TEST; + /** + * @brief In case of a status reply to a single axis self test command, this function + * searches for the actual pending command. + */ + ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id); - bool selfTestPerformed = false; + /** + * @brief Each reply contains a status byte giving information about a request. This function + * parses this byte and returns the associated failure message. + * + * @param packet Pointer to the received message containing the status byte. + * + * @return The return code derived from the received status byte. + */ + ReturnValue_t parseStatusByte(const uint8_t* packet); - /** - * @brief In case of a status reply to a single axis self test command, this function - * searches for the actual pending command. - */ - ReturnValue_t getSelfTestCommandId(DeviceCommandId_t* id); + /** + * @brief This function fills the engineering housekeeping dataset with the received data. - /** - * @brief Each reply contains a status byte giving information about a request. This function - * parses this byte and returns the associated failure message. - * - * @param packet Pointer to the received message containing the status byte. - * - * @return The return code derived from the received status byte. - */ - ReturnValue_t parseStatusByte(const uint8_t* packet); + * @param packet Pointer to the received data. + * + */ + void fillEngHkDataset(const uint8_t* packet); - /** - * @brief This function fills the engineering housekeeping dataset with the received data. + /** + * @brief This function sends a command reply to the requesting queue. + * + * @param data Pointer to the data to send. + * @param dataSize Size of the data to send. + * @param relplyId Reply id which will be inserted at the beginning of the action message. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - * @param packet Pointer to the received data. - * - */ - void fillEngHkDataset(const uint8_t* packet); + /** + * @brief This function handles the reply containing the commanded dipole. + * + * @param packet Pointer to the reply data. + */ + void handleGetCommandedDipoleReply(const uint8_t* packet); - /** - * @brief This function sends a command reply to the requesting queue. - * - * @param data Pointer to the data to send. - * @param dataSize Size of the data to send. - * @param relplyId Reply id which will be inserted at the beginning of the action message. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function parses the reply containing the calibrated MTM measurement and writes + * the values to the appropriate dataset. + * @param packet Pointer to the reply data. + */ + void fillCalibratedMtmDataset(const uint8_t* packet); - /** - * @brief This function handles the reply containing the commanded dipole. - * - * @param packet Pointer to the reply data. - */ - void handleGetCommandedDipoleReply(const uint8_t* packet); + /** + * @brief This function copies the raw MTM measurements to the MTM raw dataset. + * @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS + * command. + */ + void fillRawMtmDataset(const uint8_t* packet); - /** - * @brief This function parses the reply containing the calibrated MTM measurement and writes - * the values to the appropriate dataset. - * @param packet Pointer to the reply data. - */ - void fillCalibratedMtmDataset(const uint8_t* packet); + /** + * @brief This function handles all self test results. This comprises parsing the error byte + * and step byte and calling the function to fill the respective dataset. + */ + void handleSelfTestReply(const uint8_t* packet); - /** - * @brief This function copies the raw MTM measurements to the MTM raw dataset. - * @param packet Pointer to the reply data requested with the GET_RAW_MTM_MEASUREMENTS - * command. - */ - void fillRawMtmDataset(const uint8_t* packet); + /** + * @brief The following functions fill the respective dataset of the single axis self tests. + * @param packet Pointer to the reply data holding the self test result. + */ + void handlePositiveXSelfTestReply(const uint8_t* packet); + void handleNegativeXSelfTestReply(const uint8_t* packet); + void handlePositiveYSelfTestReply(const uint8_t* packet); + void handleNegativeYSelfTestReply(const uint8_t* packet); + void handlePositiveZSelfTestReply(const uint8_t* packet); + void handleNegativeZSelfTestReply(const uint8_t* packet); - /** - * @brief This function handles all self test results. This comprises parsing the error byte - * and step byte and calling the function to fill the respective dataset. - */ - void handleSelfTestReply(const uint8_t* packet); + /** + * @brief This function checks the error byte of a self test measurement. + * + * @param errorByte The received error byte to check + * @param step The step of the error byte. + */ + void checkErrorByte(const uint8_t errorByte, const uint8_t step); - /** - * @brief The following functions fill the respective dataset of the single axis self tests. - * @param packet Pointer to the reply data holding the self test result. - */ - void handlePositiveXSelfTestReply(const uint8_t* packet); - void handleNegativeXSelfTestReply(const uint8_t* packet); - void handlePositiveYSelfTestReply(const uint8_t* packet); - void handleNegativeYSelfTestReply(const uint8_t* packet); - void handlePositiveZSelfTestReply(const uint8_t* packet); - void handleNegativeZSelfTestReply(const uint8_t* packet); - - /** - * @brief This function checks the error byte of a self test measurement. - * - * @param errorByte The received error byte to check - * @param step The step of the error byte. - */ - void checkErrorByte(const uint8_t errorByte, const uint8_t step); - - std::string makeStepString(const uint8_t step); + std::string makeStepString(const uint8_t step); }; #endif /* MISSION_DEVICES_IMTQHANDLER_H_ */ diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index 750d56e5..809e669b 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -1,546 +1,531 @@ #include "Max31865PT1000Handler.h" -#include "fsfw/datapool/PoolReadGuard.h" - #include #include +#include "fsfw/datapool/PoolReadGuard.h" + Max31865PT1000Handler::Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, - CookieIF *comCookie): - DeviceHandlerBase(objectId, comIF, comCookie), - sensorDataset(this), sensorDatasetSid(sensorDataset.getSid()) { + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), + sensorDataset(this), + sensorDatasetSid(sensorDataset.getSid()) { #if OBSW_VERBOSE_LEVEL >= 1 - debugDivider = new PeriodicOperationDivider(10); + debugDivider = new PeriodicOperationDivider(10); #endif } -Max31865PT1000Handler::~Max31865PT1000Handler() { -} +Max31865PT1000Handler::~Max31865PT1000Handler() {} void Max31865PT1000Handler::doStartUp() { - if(internalState == InternalState::NONE) { - internalState = InternalState::WARMUP; - Clock::getUptime(&startTime); - } + if (internalState == InternalState::NONE) { + internalState = InternalState::WARMUP; + Clock::getUptime(&startTime); + } - if(internalState == InternalState::WARMUP) { - dur_millis_t timeNow = 0; - Clock::getUptime(&timeNow); - if(timeNow - startTime >= 100) { - internalState = InternalState::CONFIGURE; - } + if (internalState == InternalState::WARMUP) { + dur_millis_t timeNow = 0; + Clock::getUptime(&timeNow); + if (timeNow - startTime >= 100) { + internalState = InternalState::CONFIGURE; } + } - if(internalState == InternalState::CONFIGURE) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::REQUEST_CONFIG; - } + if (internalState == InternalState::CONFIGURE) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::REQUEST_CONFIG; } + } - if(internalState == InternalState::REQUEST_CONFIG) { - if (commandExecuted) { - commandExecuted = false; - internalState = InternalState::CONFIG_HIGH_THRESHOLD; - } + if (internalState == InternalState::REQUEST_CONFIG) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::CONFIG_HIGH_THRESHOLD; } + } - if(internalState == InternalState::CONFIG_HIGH_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::REQUEST_HIGH_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::CONFIG_HIGH_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::REQUEST_HIGH_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::REQUEST_HIGH_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::CONFIG_LOW_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::REQUEST_HIGH_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::CONFIG_LOW_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::CONFIG_LOW_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::REQUEST_LOW_THRESHOLD; - commandExecuted = false; - } + if (internalState == InternalState::CONFIG_LOW_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::REQUEST_LOW_THRESHOLD; + commandExecuted = false; } + } - if(internalState == InternalState::REQUEST_LOW_THRESHOLD) { - if(commandExecuted) { - internalState = InternalState::CLEAR_FAULT_BYTE; - commandExecuted = false; - } + if (internalState == InternalState::REQUEST_LOW_THRESHOLD) { + if (commandExecuted) { + internalState = InternalState::CLEAR_FAULT_BYTE; + commandExecuted = false; } - if(internalState == InternalState::CLEAR_FAULT_BYTE) { - if(commandExecuted) { - commandExecuted = false; - internalState = InternalState::RUNNING; - if(instantNormal) { - setMode(MODE_NORMAL); - } else { - setMode(_MODE_TO_ON); - } - } + } + if (internalState == InternalState::CLEAR_FAULT_BYTE) { + if (commandExecuted) { + commandExecuted = false; + internalState = InternalState::RUNNING; + if (instantNormal) { + setMode(MODE_NORMAL); + } else { + setMode(_MODE_TO_ON); + } } + } } void Max31865PT1000Handler::doShutDown() { - commandExecuted = false; - setMode(_MODE_POWER_DOWN); + commandExecuted = false; + setMode(_MODE_POWER_DOWN); } -ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand( - DeviceCommandId_t *id) { - if(internalState == InternalState::RUNNING) { - *id = Max31865Definitions::REQUEST_RTD; - return buildCommandFromCommand(*id, nullptr, 0); - } - else if(internalState == InternalState::REQUEST_FAULT_BYTE) { - *id = Max31865Definitions::REQUEST_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); - } - else if(internalState == InternalState::CLEAR_FAULT_BYTE) { - *id = Max31865Definitions::CLEAR_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); - } - else { - return DeviceHandlerBase::NOTHING_TO_SEND; - } -} - -ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand( - DeviceCommandId_t *id) { - switch(internalState) { - case(InternalState::NONE): - case(InternalState::WARMUP): - case(InternalState::RUNNING): +ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (internalState == InternalState::RUNNING) { + *id = Max31865Definitions::REQUEST_RTD; + return buildCommandFromCommand(*id, nullptr, 0); + } else if (internalState == InternalState::REQUEST_FAULT_BYTE) { + *id = Max31865Definitions::REQUEST_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else if (internalState == InternalState::CLEAR_FAULT_BYTE) { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); + } else { return DeviceHandlerBase::NOTHING_TO_SEND; - case(InternalState::CONFIGURE): { - *id = Max31865Definitions::CONFIG_CMD; - uint8_t config[1] = {DEFAULT_CONFIG}; - return buildCommandFromCommand(*id, config, 1); + } +} + +ReturnValue_t Max31865PT1000Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + switch (internalState) { + case (InternalState::NONE): + case (InternalState::WARMUP): + case (InternalState::RUNNING): + return DeviceHandlerBase::NOTHING_TO_SEND; + case (InternalState::CONFIGURE): { + *id = Max31865Definitions::CONFIG_CMD; + uint8_t config[1] = {DEFAULT_CONFIG}; + return buildCommandFromCommand(*id, config, 1); } - case(InternalState::REQUEST_CONFIG): { - *id = Max31865Definitions::REQUEST_CONFIG; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_CONFIG): { + *id = Max31865Definitions::REQUEST_CONFIG; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CONFIG_HIGH_THRESHOLD): { - *id = Max31865Definitions::WRITE_HIGH_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CONFIG_HIGH_THRESHOLD): { + *id = Max31865Definitions::WRITE_HIGH_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::REQUEST_HIGH_THRESHOLD): { - *id = Max31865Definitions::REQUEST_HIGH_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_HIGH_THRESHOLD): { + *id = Max31865Definitions::REQUEST_HIGH_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CONFIG_LOW_THRESHOLD): { - *id = Max31865Definitions::WRITE_LOW_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CONFIG_LOW_THRESHOLD): { + *id = Max31865Definitions::WRITE_LOW_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::REQUEST_LOW_THRESHOLD): { - *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::REQUEST_LOW_THRESHOLD): { + *id = Max31865Definitions::REQUEST_LOW_THRESHOLD; + return buildCommandFromCommand(*id, nullptr, 0); } - case(InternalState::CLEAR_FAULT_BYTE): { - *id = Max31865Definitions::CLEAR_FAULT_BYTE; - return buildCommandFromCommand(*id, nullptr, 0); + case (InternalState::CLEAR_FAULT_BYTE): { + *id = Max31865Definitions::CLEAR_FAULT_BYTE; + return buildCommandFromCommand(*id, nullptr, 0); } default: #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl; + sif::error << "Max31865PT1000Handler: Invalid internal state" << std::endl; #else - sif::printError("Max31865PT1000Handler: Invalid internal state\n"); + sif::printError("Max31865PT1000Handler: Invalid internal state\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; + } } -ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(Max31865Definitions::CONFIG_CMD) : { - commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); - if(commandDataLen == 1) { - commandBuffer[1] = commandData[0]; - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; - } - else { - return DeviceHandlerIF::NO_COMMAND_DATA; - } - } - case(Max31865Definitions::CLEAR_FAULT_BYTE): { - commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); - commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; +ReturnValue_t Max31865PT1000Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (Max31865Definitions::CONFIG_CMD): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + if (commandDataLen == 1) { + commandBuffer[1] = commandData[0]; DeviceHandlerBase::rawPacketLen = 2; DeviceHandlerBase::rawPacket = commandBuffer.data(); return HasReturnvaluesIF::RETURN_OK; + } else { + return DeviceHandlerIF::NO_COMMAND_DATA; + } } - case(Max31865Definitions::REQUEST_CONFIG): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_CONFIG); - commandBuffer[1] = 0x00; // dummy byte - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::CLEAR_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::CONFIG_CMD); + commandBuffer[1] = Max31865Definitions::CLEAR_FAULT_BIT_VAL; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::WRITE_HIGH_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::WRITE_HIGH_THRESHOLD); - commandBuffer[1] = static_cast(HIGH_THRESHOLD >> 8); - commandBuffer[2] = static_cast(HIGH_THRESHOLD & 0xFF); - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_CONFIG): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_CONFIG); + commandBuffer[1] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_HIGH_THRESHOLD); - commandBuffer[1] = 0x00; //dummy byte - commandBuffer[2] = 0x00; //dummy byte - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::WRITE_HIGH_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::WRITE_HIGH_THRESHOLD); + commandBuffer[1] = static_cast(HIGH_THRESHOLD >> 8); + commandBuffer[2] = static_cast(HIGH_THRESHOLD & 0xFF); + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::WRITE_LOW_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::WRITE_LOW_THRESHOLD); - commandBuffer[1] = static_cast(LOW_THRESHOLD >> 8); - commandBuffer[2] = static_cast(LOW_THRESHOLD & 0xFF); - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_HIGH_THRESHOLD); + commandBuffer[1] = 0x00; // dummy byte + commandBuffer[2] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_LOW_THRESHOLD); - commandBuffer[1] = 0x00; //dummy byte - commandBuffer[2] = 0x00; //dummy byte - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::WRITE_LOW_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::WRITE_LOW_THRESHOLD); + commandBuffer[1] = static_cast(LOW_THRESHOLD >> 8); + commandBuffer[2] = static_cast(LOW_THRESHOLD & 0xFF); + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_RTD): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_RTD); - // two dummy bytes - commandBuffer[1] = 0x00; - commandBuffer[2] = 0x00; - DeviceHandlerBase::rawPacketLen = 3; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_LOW_THRESHOLD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_LOW_THRESHOLD); + commandBuffer[1] = 0x00; // dummy byte + commandBuffer[2] = 0x00; // dummy byte + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } - case(Max31865Definitions::REQUEST_FAULT_BYTE): { - commandBuffer[0] = static_cast( - Max31865Definitions::REQUEST_FAULT_BYTE); - commandBuffer[1] = 0x00; - DeviceHandlerBase::rawPacketLen = 2; - DeviceHandlerBase::rawPacket = commandBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + case (Max31865Definitions::REQUEST_RTD): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_RTD); + // two dummy bytes + commandBuffer[1] = 0x00; + commandBuffer[2] = 0x00; + DeviceHandlerBase::rawPacketLen = 3; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; + } + case (Max31865Definitions::REQUEST_FAULT_BYTE): { + commandBuffer[0] = static_cast(Max31865Definitions::REQUEST_FAULT_BYTE); + commandBuffer[1] = 0x00; + DeviceHandlerBase::rawPacketLen = 2; + DeviceHandlerBase::rawPacket = commandBuffer.data(); + return HasReturnvaluesIF::RETURN_OK; } default: - //Unknown DeviceCommand - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } + // Unknown DeviceCommand + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } } void Max31865PT1000Handler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3); - insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, - &sensorDataset); - insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); - insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CONFIG_CMD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_CONFIG, 3); + insertInCommandAndReplyMap(Max31865Definitions::WRITE_LOW_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_LOW_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::WRITE_HIGH_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_HIGH_THRESHOLD, 3); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_RTD, 3, &sensorDataset); + insertInCommandAndReplyMap(Max31865Definitions::REQUEST_FAULT_BYTE, 3); + insertInCommandAndReplyMap(Max31865Definitions::CLEAR_FAULT_BYTE, 3); } -ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - size_t rtdReplySize = 3; - size_t configReplySize = 2; - - if(remainingSize == rtdReplySize and - internalState == InternalState::RUNNING) { - *foundId = Max31865Definitions::REQUEST_RTD; - *foundLen = rtdReplySize; - return RETURN_OK; - } - - if(remainingSize == 3) { - switch(internalState) { - case(InternalState::CONFIG_HIGH_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD; - commandExecuted = true; - return RETURN_OK; - } - case(InternalState::REQUEST_HIGH_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD; - return RETURN_OK; - } - case(InternalState::CONFIG_LOW_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::WRITE_LOW_THRESHOLD; - commandExecuted = true; - return RETURN_OK; - } - case(InternalState::REQUEST_LOW_THRESHOLD): { - *foundLen = 3; - *foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD; - return RETURN_OK; - } - default: { - sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state" - << std::endl; - return RETURN_OK; - } - } - } - - if(remainingSize == configReplySize) { - if(internalState == InternalState::CONFIGURE) { - commandExecuted = true; - *foundLen = configReplySize; - *foundId = Max31865Definitions::CONFIG_CMD; - } - else if(internalState == InternalState::REQUEST_FAULT_BYTE) { - *foundId = Max31865Definitions::REQUEST_FAULT_BYTE; - *foundLen = 2; - internalState = InternalState::RUNNING; - } - else if(internalState == InternalState::CLEAR_FAULT_BYTE) { - *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; - *foundLen = 2; - if(mode == _MODE_START_UP) { - commandExecuted = true; - } else { - internalState = InternalState::RUNNING; - } - } - else { - *foundId = Max31865Definitions::REQUEST_CONFIG; - *foundLen = configReplySize; - } - } +ReturnValue_t Max31865PT1000Handler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + size_t rtdReplySize = 3; + size_t configReplySize = 2; + if (remainingSize == rtdReplySize and internalState == InternalState::RUNNING) { + *foundId = Max31865Definitions::REQUEST_RTD; + *foundLen = rtdReplySize; return RETURN_OK; + } + + if (remainingSize == 3) { + switch (internalState) { + case (InternalState::CONFIG_HIGH_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::WRITE_HIGH_THRESHOLD; + commandExecuted = true; + return RETURN_OK; + } + case (InternalState::REQUEST_HIGH_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::REQUEST_HIGH_THRESHOLD; + return RETURN_OK; + } + case (InternalState::CONFIG_LOW_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::WRITE_LOW_THRESHOLD; + commandExecuted = true; + return RETURN_OK; + } + case (InternalState::REQUEST_LOW_THRESHOLD): { + *foundLen = 3; + *foundId = Max31865Definitions::REQUEST_LOW_THRESHOLD; + return RETURN_OK; + } + default: { + sif::debug << "Max31865PT1000Handler::scanForReply: Unknown internal state" << std::endl; + return RETURN_OK; + } + } + } + + if (remainingSize == configReplySize) { + if (internalState == InternalState::CONFIGURE) { + commandExecuted = true; + *foundLen = configReplySize; + *foundId = Max31865Definitions::CONFIG_CMD; + } else if (internalState == InternalState::REQUEST_FAULT_BYTE) { + *foundId = Max31865Definitions::REQUEST_FAULT_BYTE; + *foundLen = 2; + internalState = InternalState::RUNNING; + } else if (internalState == InternalState::CLEAR_FAULT_BYTE) { + *foundId = Max31865Definitions::CLEAR_FAULT_BYTE; + *foundLen = 2; + if (mode == _MODE_START_UP) { + commandExecuted = true; + } else { + internalState = InternalState::RUNNING; + } + } else { + *foundId = Max31865Definitions::REQUEST_CONFIG; + *foundLen = configReplySize; + } + } + + return RETURN_OK; } -ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( - DeviceCommandId_t id, const uint8_t *packet) { - switch(id) { - case(Max31865Definitions::REQUEST_CONFIG): { - if(packet[1] != DEFAULT_CONFIG) { +ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) { + switch (id) { + case (Max31865Definitions::REQUEST_CONFIG): { + if (packet[1] != DEFAULT_CONFIG) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - // it propably would be better if we at least try one restart.. - sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() - << ": Invalid configuration reply" << std::endl; + // it propably would be better if we at least try one restart.. + sif::error << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId() + << ": Invalid configuration reply" << std::endl; #else - sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", - this->getObjectId()); + sif::printError("Max31865PT1000Handler: %04x: Invalid configuration reply!\n", + this->getObjectId()); #endif - return HasReturnvaluesIF::RETURN_OK; - } - // set to true for invalid configs too for now. - if(internalState == InternalState::REQUEST_CONFIG) { - commandExecuted = true; - } - else if(internalState == InternalState::RUNNING) { - // we should propably generate a telemetry with the config byte - // as payload here. - } - break; + return HasReturnvaluesIF::RETURN_OK; + } + // set to true for invalid configs too for now. + if (internalState == InternalState::REQUEST_CONFIG) { + commandExecuted = true; + } else if (internalState == InternalState::RUNNING) { + // we should propably generate a telemetry with the config byte + // as payload here. + } + break; } - case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { - uint16_t readLowThreshold = packet[1] << 8 | packet[2]; - if(readLowThreshold != LOW_THRESHOLD) { + case (Max31865Definitions::REQUEST_LOW_THRESHOLD): { + uint16_t readLowThreshold = packet[1] << 8 | packet[2]; + if (readLowThreshold != LOW_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << - std::hex << this->getObjectId() << ": Missmatch between " << - "written and readback value of low threshold register" << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Missmatch between " + << "written and readback value of low threshold register" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " - "written and readback value of low threshold register\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of low threshold register\n"); #endif #endif - } - commandExecuted = true; - break; + } + commandExecuted = true; + break; } - case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { - uint16_t readHighThreshold = packet[1] << 8 | packet[2]; - if(readHighThreshold != HIGH_THRESHOLD) { + case (Max31865Definitions::REQUEST_HIGH_THRESHOLD): { + uint16_t readHighThreshold = packet[1] << 8 | packet[2]; + if (readHighThreshold != HIGH_THRESHOLD) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Missmatch between " << - "written and readback value of high threshold register" << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Missmatch between " + << "written and readback value of high threshold register" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Missmatch between " - "written and readback value of high threshold register\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Missmatch between " + "written and readback value of high threshold register\n"); #endif #endif - } - commandExecuted = true; - break; + } + commandExecuted = true; + break; } - case(Max31865Definitions::REQUEST_RTD): { - // first bit of LSB reply byte is the fault bit - uint8_t faultBit = packet[2] & 0b0000'0001; - if(resetFaultBit) { - internalState = InternalState::CLEAR_FAULT_BYTE; - resetFaultBit = false; - } - else if(faultBit == 1) { - // Maybe we should attempt to restart it? - internalState = InternalState::REQUEST_FAULT_BYTE; - resetFaultBit = true; - } + case (Max31865Definitions::REQUEST_RTD): { + // first bit of LSB reply byte is the fault bit + uint8_t faultBit = packet[2] & 0b0000'0001; + if (resetFaultBit) { + internalState = InternalState::CLEAR_FAULT_BYTE; + resetFaultBit = false; + } else if (faultBit == 1) { + // Maybe we should attempt to restart it? + internalState = InternalState::REQUEST_FAULT_BYTE; + resetFaultBit = true; + } - // RTD value consists of last seven bits of the LSB reply byte and - // the MSB reply byte - uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1; - // do something with rtd value, will propably be stored in - // dataset. - float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX; - // calculate approximation - float approxTemp = adcCode / 32.0 - 256.0; + // RTD value consists of last seven bits of the LSB reply byte and + // the MSB reply byte + uint16_t adcCode = ((packet[1] << 8) | packet[2]) >> 1; + // do something with rtd value, will propably be stored in + // dataset. + float rtdValue = adcCode * RTD_RREF_PT1000 / INT16_MAX; + // calculate approximation + float approxTemp = adcCode / 32.0 - 256.0; #if OBSW_DEBUG_RTD == 1 #if OBSW_VERBOSE_LEVEL >= 1 - if(debugDivider->checkAndIncrement()) { + if (debugDivider->checkAndIncrement()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId() - << ": Measured resistance is " << rtdValue << " Ohms." << std::endl; - sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; + sif::info << "Max31865: Object ID: " << std::hex << this->getObjectId() + << ": Measured resistance is " << rtdValue << " Ohms." << std::endl; + sif::info << "Approximated temperature is " << approxTemp << " C" << std::endl; #else - sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); - sif::printInfo("Approximated temperature is %f C\n", approxTemp); + sif::printInfo("Max31685: Measured resistance is %f Ohms\n", rtdValue); + sif::printInfo("Approximated temperature is %f C\n", approxTemp); #endif - } + } #endif #endif - PoolReadGuard pg(&sensorDataset); - if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + PoolReadGuard pg(&sensorDataset); + if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Error reading dataset!" - << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Error reading dataset!" << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: " - "Error reading dataset!\n"); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error reading dataset!\n"); #endif - return pg.getReadResult(); - } + return pg.getReadResult(); + } - if(not sensorDataset.isValid()) { - sensorDataset.setValidity(true, false); - sensorDataset.rtdValue.setValid(true); - sensorDataset.temperatureCelcius.setValid(true); - } + if (not sensorDataset.isValid()) { + sensorDataset.setValidity(true, false); + sensorDataset.rtdValue.setValid(true); + sensorDataset.temperatureCelcius.setValid(true); + } - sensorDataset.rtdValue = rtdValue; - sensorDataset.temperatureCelcius = approxTemp; - break; + sensorDataset.rtdValue = rtdValue; + sensorDataset.temperatureCelcius = approxTemp; + break; } - case(Max31865Definitions::REQUEST_FAULT_BYTE): { - faultByte = packet[1]; + case (Max31865Definitions::REQUEST_FAULT_BYTE): { + faultByte = packet[1]; #if OBSW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " - << std::hex << this->getObjectId() << ": Fault byte" - " is: 0b" << std::bitset<8>(faultByte) << std::endl; + sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() + << ": Fault byte" + " is: 0b" + << std::bitset<8>(faultByte) << std::endl; #else - sif::printWarning("Max31865PT1000Handler::interpretDeviceReply: Fault byte" - " is: 0b" BYTE_TO_BINARY_PATTERN "\n", BYTE_TO_BINARY(faultByte)); + sif::printWarning( + "Max31865PT1000Handler::interpretDeviceReply: Fault byte" + " is: 0b" BYTE_TO_BINARY_PATTERN "\n", + BYTE_TO_BINARY(faultByte)); #endif #endif - ReturnValue_t result = sensorDataset.read(); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + ReturnValue_t result = sensorDataset.read(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex - << this->getObjectId() << ":" - "Error reading dataset!" << std::endl; + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() + << ":" + "Error reading dataset!" + << std::endl; #else - sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " - "Error reading dataset!\n"); + sif::printDebug( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error reading dataset!\n"); #endif - return result; - } - sensorDataset.errorByte.setValid(true); - sensorDataset.errorByte = faultByte; - if(faultByte != 0) { - sensorDataset.temperatureCelcius.setValid(false); - } + return result; + } + sensorDataset.errorByte.setValid(true); + sensorDataset.errorByte = faultByte; + if (faultByte != 0) { + sensorDataset.temperatureCelcius.setValid(false); + } - result = sensorDataset.commit(); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Configuration error + result = sensorDataset.commit(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex - << this->getObjectId() << ": Error commiting dataset!" << std::endl; + sif::debug << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex + << this->getObjectId() << ": Error commiting dataset!" << std::endl; #else - sif::printDebug("Max31865PT1000Handler::interpretDeviceReply: " - "Error commiting dataset!\n"); + sif::printDebug( + "Max31865PT1000Handler::interpretDeviceReply: " + "Error commiting dataset!\n"); #endif - return result; - } + return result; + } - break; + break; } default: - break; - } - return HasReturnvaluesIF::RETURN_OK; + break; + } + return HasReturnvaluesIF::RETURN_OK; } -void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, - object_id_t objectId, uint32_t parameter) { +void Max31865PT1000Handler::debugInterface(uint8_t positionTracker, object_id_t objectId, + uint32_t parameter) {} + +uint32_t Max31865PT1000Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 25000; } -uint32_t Max31865PT1000Handler::getTransitionDelayMs( - Mode_t modeFrom, Mode_t modeTo) { - return 25000; +ReturnValue_t Max31865PT1000Handler::getSwitches(const uint8_t **switches, + uint8_t *numberOfSwitches) { + return DeviceHandlerBase::NO_SWITCH; } -ReturnValue_t Max31865PT1000Handler::getSwitches( - const uint8_t **switches, uint8_t *numberOfSwitches) { - return DeviceHandlerBase::NO_SWITCH; +void Max31865PT1000Handler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); } -void Max31865PT1000Handler::doTransition(Mode_t modeFrom, - Submode_t subModeFrom) { - DeviceHandlerBase::doTransition(modeFrom, subModeFrom); -} - -ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C, - new PoolEntry({0}, 1, true)); - localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, - new PoolEntry({0})); -// poolManager.subscribeForPeriodicPacket(sensorDatasetSid, -// false, 4.0, false); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C, + new PoolEntry({0}, 1, true)); + localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, new PoolEntry({0})); + // poolManager.subscribeForPeriodicPacket(sensorDatasetSid, + // false, 4.0, false); + return HasReturnvaluesIF::RETURN_OK; } void Max31865PT1000Handler::setInstantNormal(bool instantNormal) { - this->instantNormal = instantNormal; + this->instantNormal = instantNormal; } void Max31865PT1000Handler::modeChanged() { - if(mode == MODE_OFF) { - internalState = InternalState::NONE; - } + if (mode == MODE_OFF) { + internalState = InternalState::NONE; + } } diff --git a/mission/devices/Max31865PT1000Handler.h b/mission/devices/Max31865PT1000Handler.h index 3be16150..44d7a2e7 100644 --- a/mission/devices/Max31865PT1000Handler.h +++ b/mission/devices/Max31865PT1000Handler.h @@ -2,12 +2,12 @@ #define MISSION_DEVICES_MAX31865PT1000HANDLER_H_ #include - #include #include #include #include + #include "devicedefinitions/Max31865Definitions.h" /** @@ -28,95 +28,92 @@ * @author R. Mueller * @ingroup devices */ -class Max31865PT1000Handler: public DeviceHandlerBase { -public: - Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual~ Max31865PT1000Handler(); +class Max31865PT1000Handler : public DeviceHandlerBase { + public: + Max31865PT1000Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~Max31865PT1000Handler(); - // Configuration in 8 digit code: - // 1. 1 for V_BIAS enabled, 0 for disabled - // 2. 1 for Auto-conversion, 0 for off - // 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit) - // 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD) - // 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1 - // 0 for run fault detection with manual delay, - // 11 for finish fault detection with manual delay - // 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards) - // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) - static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; + // Configuration in 8 digit code: + // 1. 1 for V_BIAS enabled, 0 for disabled + // 2. 1 for Auto-conversion, 0 for off + // 3. 1 for 1-shot enabled, 0 for disabled (self-clearing bit) + // 4. 1 for 3-wire enabled, 0 for disabled (two and four wired RTD) + // 5./6. Fault detection: 00 for no action, 01 for automatic delay, 1 + // 0 for run fault detection with manual delay, + // 11 for finish fault detection with manual delay + // 7. Fault status: Write 1 to reset fault status register (Bit is self cleared afterwards) + // 8. 1 for 50 Hz filter, 0 for 60 Hz filter (noise rejection filter) + static constexpr uint8_t DEFAULT_CONFIG = 0b11000001; - void setInstantNormal(bool instantNormal); - /** - * Expected temperature range is -100 C and 100 C. - * If there are temperatures beyond this range there must be a fault. - * The threshold variables cause the MAX1385 to signal an error in case the measured resistance - * indicates a temperature higher than 100 C or lower than -100 C. - * Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the - * low threshold register. - */ - static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C - static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C + void setInstantNormal(bool instantNormal); + /** + * Expected temperature range is -100 C and 100 C. + * If there are temperatures beyond this range there must be a fault. + * The threshold variables cause the MAX1385 to signal an error in case the measured resistance + * indicates a temperature higher than 100 C or lower than -100 C. + * Default settings of MAX13865 are 0xFFFF for the high threshold register and 0x0 for the + * low threshold register. + */ + static constexpr uint16_t HIGH_THRESHOLD = 11298; // = 100 C + static constexpr uint16_t LOW_THRESHOLD = 4902; // = -100 C - static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm - static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm -protected: - // DeviceHandlerBase abstract function implementation - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) override; - void fillCommandAndReplyMap() 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; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t getSwitches(const uint8_t **switches, - uint8_t *numberOfSwitches) override; + static constexpr float RTD_RREF_PT1000 = 4020.0; //!< Ohm + static constexpr float RTD_RESISTANCE0_PT1000 = 1000.0; //!< Ohm + protected: + // DeviceHandlerBase abstract function implementation + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + void fillCommandAndReplyMap() 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; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; - void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; + void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; - void debugInterface(uint8_t positionTracker = 0, - object_id_t objectId = 0, uint32_t parameter = 0) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - void modeChanged() override; + void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0, + uint32_t parameter = 0) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; + void modeChanged() override; -private: - uint8_t switchId = 0; - bool instantNormal = true; + private: + uint8_t switchId = 0; + bool instantNormal = true; - enum class InternalState { - NONE, - WARMUP, - CONFIGURE, - CONFIG_HIGH_THRESHOLD, - REQUEST_HIGH_THRESHOLD, - CONFIG_LOW_THRESHOLD, - REQUEST_LOW_THRESHOLD, - REQUEST_CONFIG, - RUNNING, - REQUEST_FAULT_BYTE, - CLEAR_FAULT_BYTE - }; + enum class InternalState { + NONE, + WARMUP, + CONFIGURE, + CONFIG_HIGH_THRESHOLD, + REQUEST_HIGH_THRESHOLD, + CONFIG_LOW_THRESHOLD, + REQUEST_LOW_THRESHOLD, + REQUEST_CONFIG, + RUNNING, + REQUEST_FAULT_BYTE, + CLEAR_FAULT_BYTE + }; - InternalState internalState = InternalState::NONE; - bool commandExecuted = false; + InternalState internalState = InternalState::NONE; + bool commandExecuted = false; - bool resetFaultBit = false; - dur_millis_t startTime = 0; - uint8_t faultByte = 0; - std::array commandBuffer { 0 }; + bool resetFaultBit = false; + dur_millis_t startTime = 0; + uint8_t faultByte = 0; + std::array commandBuffer{0}; - Max31865Definitions::Max31865Set sensorDataset; - sid_t sensorDatasetSid; + Max31865Definitions::Max31865Set sensorDataset; + sid_t sensorDatasetSid; #if OBSW_VERBOSE_LEVEL >= 1 - PeriodicOperationDivider* debugDivider; + PeriodicOperationDivider *debugDivider; #endif }; #endif /* MISSION_DEVICES_MAX31865PT1000HANDLER_H_ */ - diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 4ade2a0b..a89debc6 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -1,480 +1,506 @@ -#include #include "P60DockHandler.h" + +#include + #include "OBSWConfig.h" -P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, - P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, &p60dockHkTableDataset), p60dockHkTableDataset( - this) { -} +P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, + P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE, + &p60dockHkTableDataset), + p60dockHkTableDataset(this) {} -P60DockHandler::~P60DockHandler() { -} +P60DockHandler::~P60DockHandler() {} -ReturnValue_t P60DockHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +ReturnValue_t P60DockHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - /** - * Hk table will be sent to the commander if hk table request was not triggered by the - * P60DockHandler itself. - */ - handleDeviceTM(&p60dockHkTableDataset, id, true); + parseHkTableReply(packet); + /** + * Hk table will be sent to the commander if hk table request was not triggered by the + * P60DockHandler itself. + */ + handleDeviceTM(&p60dockHkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_P60DOCK == 1 - p60dockHkTableDataset.read(); - sif::info << "P60 Dock: ACU VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << std::endl; - sif::info << "P60 Dock: PDU1 VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << std::endl; - sif::info << "P60 Dock: PDU2 VCC switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << std::endl; - sif::info << "P60 Dock: ACU VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << std::endl; - sif::info << "P60 Dock: PDU1 VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << std::endl; - sif::info << "P60 Dock: PDU2 VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << std::endl; - sif::info << "P60 Dock: Stack VBAT switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStackVbat.value) << std::endl; - sif::info << "P60 Dock: Stack 3V3 switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStack3V3.value) << std::endl; - sif::info << "P60 Dock: Stack 5V switch: " << - static_cast(p60dockHkTableDataset.outputEnableStateStack5V.value) << std::endl; + p60dockHkTableDataset.read(); + sif::info << "P60 Dock: ACU VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) + << std::endl; + sif::info << "P60 Dock: PDU1 VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) + << std::endl; + sif::info << "P60 Dock: PDU2 VCC switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) + << std::endl; + sif::info << "P60 Dock: ACU VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateAcuVbat.value) + << std::endl; + sif::info << "P60 Dock: PDU1 VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) + << std::endl; + sif::info << "P60 Dock: PDU2 VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) + << std::endl; + sif::info << "P60 Dock: Stack VBAT switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStackVbat.value) + << std::endl; + sif::info << "P60 Dock: Stack 3V3 switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStack3V3.value) + << std::endl; + sif::info << "P60 Dock: Stack 5V switch: " + << static_cast(p60dockHkTableDataset.outputEnableStateStack5V.value) + << std::endl; - float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1; - sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl; - temperatureC = p60dockHkTableDataset.temperature2.value * 0.1; - sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl; - sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: " + float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1; + sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl; + temperatureC = p60dockHkTableDataset.temperature2.value * 0.1; + sif::info << "P60 Dock: Temperature 2: " << temperatureC << " °C" << std::endl; + sif::info << "P60 Dock: Watchdog Timer seconds left before reboot: " << p60dockHkTableDataset.wdtGndLeft << " seconds" << std::endl; - sif::info << "P60 Dock: CSP 1, pings left before reboot: " - << (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl; - sif::info << "P60 Dock: CSP 2, pings left before reboot: " - << (int) p60dockHkTableDataset.wdtCspLeft1.value << std::endl; + sif::info << "P60 Dock: CSP 1, pings left before reboot: " + << (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl; + sif::info << "P60 Dock: CSP 2, pings left before reboot: " + << (int)p60dockHkTableDataset.wdtCspLeft1.value << std::endl; - p60dockHkTableDataset.commit(); + p60dockHkTableDataset.commit(); #endif - } void P60DockHandler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - p60dockHkTableDataset.read(); - /** - * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. - */ - dataOffset += 12; - p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + p60dockHkTableDataset.read(); + /** + * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. + */ + dataOffset += 12; + p60dockHkTableDataset.currentAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.currentGS5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltagePdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.voltageGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.outputEnableStateAcuVcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu1Vcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateX3IdleVcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu2Vcc = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateAcuVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu1Vbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateX3IdleVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStatePdu2Vbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStackVbat = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStack3V3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateStack5V = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateGS3V3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.outputEnableStateGS5V = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.battMode = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.heaterOn = *(packet + dataOffset); - /* + 13 because here begins a new gomspace csp data field */ - dataOffset += 13; - p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.battMode = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.heaterOn = *(packet + dataOffset); + /* + 13 because here begins a new gomspace csp data field */ + dataOffset += 13; + p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsX3IdleVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsX3IdleVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStackVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu1Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsX3IdleVcc = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu2Vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsAcuVbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu1Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsX3IdleVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsPdu2Vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStackVbat = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStack3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsStack5V = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.latchupsGS3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.vbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.vccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.batteryTemperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryTemperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + p60dockHkTableDataset.batteryTemperature1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryTemperature2 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - p60dockHkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.dearmStatus = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.dearmStatus = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; + p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; - p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - /* +16 because here begins a new gomspace csp packet */ - dataOffset += 16; + p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + /* +16 because here begins a new gomspace csp packet */ + dataOffset += 16; - p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset); - dataOffset += 3; + p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset); + dataOffset += 3; - p60dockHkTableDataset.batteryChargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.batteryDischargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - p60dockHkTableDataset.ant6Depl = *(packet + dataOffset); - dataOffset += 3; - p60dockHkTableDataset.ar6Depl = *(packet + dataOffset); + p60dockHkTableDataset.batteryChargeCurrent = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.batteryDischargeCurrent = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + p60dockHkTableDataset.ant6Depl = *(packet + dataOffset); + dataOffset += 3; + p60dockHkTableDataset.ar6Depl = *(packet + dataOffset); - p60dockHkTableDataset.commit(); + p60dockHkTableDataset.commit(); } -ReturnValue_t P60DockHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CURRENT_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VOLTAGE_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_OUTPUTENABLE_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_TEMPERATURE_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BOOT_CNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_HEATER_ON, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_CONV_5V_ENABLE_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_ACU_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_STACK_5V, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_LATCHUP_GS5V, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_VBAT_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_VCC_CURRENT_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_VOLTAGE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATTERY_TEMPERATURE_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_DEARM_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CNT_CSP_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_WDT_CSP_LEFT_2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_CHARGE_CURRENT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_BATT_DISCHARGE_CURRENT, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry( { 0 })); - - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&p60dockHkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&p60dockHkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void P60DockHandler::printHkTable() { - sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << "P60 Dock Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageAcuVcc.value << std::endl; - sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentAcuVbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageAcuVbat.value << std::endl; + sif::info << std::setw(30) << std::left << "ACU VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << ", " << std::setw(4) + << std::right << p60dockHkTableDataset.currentAcuVcc.value << ", " << std::setw(5) + << p60dockHkTableDataset.voltageAcuVcc.value << std::endl; + sif::info << std::setw(30) << std::left << "ACU VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentAcuVbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageAcuVbat.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu1Vcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu1Vbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU1 VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vcc.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu1Vcc.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU1 VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu1Vbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu1Vbat.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu2Vcc.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl; - sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentPdu2Vbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU2 VCC" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vcc.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu2Vcc.value << std::endl; + sif::info << std::setw(30) << std::left << "PDU2 VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentPdu2Vbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltagePdu2Vbat.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStackVbat.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStackVbat.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStack3V3.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStack3V3.value << std::endl; - sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| " << - unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", " << - std::setw(4) << std::right << - p60dockHkTableDataset.currentStack5V.value << ", " << std::setw(5) << - p60dockHkTableDataset.voltageStack5V.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack VBAT" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStackVbat.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStackVbat.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStackVbat.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack 3V3" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStack3V3.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStack3V3.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStack3V3.value << std::endl; + sif::info << std::setw(30) << std::left << "Stack 5V" << std::dec << "| " + << unsigned(p60dockHkTableDataset.outputEnableStateStack5V.value) << ", " + << std::setw(4) << std::right << p60dockHkTableDataset.currentStack5V.value << ", " + << std::setw(5) << p60dockHkTableDataset.voltageStack5V.value << std::endl; } - diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index cee0ecec..937ef122 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -1,47 +1,47 @@ #ifndef MISSION_DEVICES_P60DOCKHANDLER_H_ #define MISSION_DEVICES_P60DOCKHANDLER_H_ -#include "GomspaceDeviceHandler.h" #include +#include "GomspaceDeviceHandler.h" /** * @brief Device handler for the P60Dock. The P60Dock serves as carrier for the ACU, PDU1 and * PDU2. Via the P60Dock each of these modules can be turned on and off individually. */ -class P60DockHandler: public GomspaceDeviceHandler { -public: - P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~P60DockHandler(); +class P60DockHandler : public GomspaceDeviceHandler { + public: + P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~P60DockHandler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: + protected: + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; + /** + * This command handles printing the HK table to the console. This is useful for debugging + * purposes + * @return + */ + ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - /** - * This command handles printing the HK table to the console. This is useful for debugging - * purposes - * @return - */ - ReturnValue_t printStatus(DeviceCommandId_t cmd) override; + void printHkTable(); - void printHkTable(); -private: - P60Dock::HkTableDataset p60dockHkTableDataset; + private: + P60Dock::HkTableDataset p60dockHkTableDataset; - /** - * @brief Function extracts the hk table information from the received csp packet and stores - * the values in the p60dockHkTableDataset. - */ - void parseHkTableReply(const uint8_t *packet); + /** + * @brief Function extracts the hk table information from the received csp packet and stores + * the values in the p60dockHkTableDataset. + */ + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_P60DOCKHANDLER_H_ */ diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index fe7294ea..13bed074 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -1,506 +1,488 @@ #include "PCDUHandler.h" + #include +#include +#include +#include #include -#include - -#include -#include - - -PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) : - SystemObject(setObjectId), poolManager(this, nullptr), pdu2HkTableDataset(this), pdu1HkTableDataset( - this), cmdQueueSize(cmdQueueSize) { - - commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, - MessageQueueMessage::MAX_MESSAGE_SIZE); +PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) + : SystemObject(setObjectId), + poolManager(this, nullptr), + pdu2HkTableDataset(this), + pdu1HkTableDataset(this), + cmdQueueSize(cmdQueueSize) { + commandQueue = QueueFactory::instance()->createMessageQueue( + cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE); } -PCDUHandler::~PCDUHandler() { -} +PCDUHandler::~PCDUHandler() {} ReturnValue_t PCDUHandler::performOperation(uint8_t counter) { - - if (counter == DeviceHandlerIF::PERFORM_OPERATION) { - readCommandQueue(); - return RETURN_OK; - } - + if (counter == DeviceHandlerIF::PERFORM_OPERATION) { + readCommandQueue(); return RETURN_OK; + } + + return RETURN_OK; } ReturnValue_t PCDUHandler::initialize() { + ReturnValue_t result; - ReturnValue_t result; + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (IPCStore == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (IPCStore == nullptr) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + result = poolManager.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - result = poolManager.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + /* Subscribing for housekeeping table update messages of the PDU2 */ + HasLocalDataPoolIF* pdu2Handler = + ObjectManager::instance()->get(objects::PDU2_HANDLER); + if (pdu2Handler == nullptr) { + sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl; + return RETURN_FAILED; + } + result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( + PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " + << "PDU2Handler" << std::endl; + return result; + } - /* Subscribing for housekeeping table update messages of the PDU2 */ - HasLocalDataPoolIF* pdu2Handler = ObjectManager::instance()->get( - objects::PDU2_HANDLER); - if(pdu2Handler == nullptr) { - sif::error << "PCDUHandler::initialize: Invalid pdu2Handler" << std::endl; - return RETURN_FAILED; - } - result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " - << "PDU2Handler" << std::endl; - return result; - } + /* Subscribing for housekeeping table update messages of the PDU1 */ + HasLocalDataPoolIF* pdu1Handler = + ObjectManager::instance()->get(objects::PDU1_HANDLER); + if (pdu1Handler == nullptr) { + sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl; + return RETURN_FAILED; + } + result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( + PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " + << "PDU1Handler" << std::endl; + return result; + } - /* Subscribing for housekeeping table update messages of the PDU1 */ - HasLocalDataPoolIF* pdu1Handler = ObjectManager::instance()->get( - objects::PDU1_HANDLER); - if(pdu1Handler == nullptr) { - sif::error << "PCDUHandler::initialize: Invalid pdu1Handler" << std::endl; - return RETURN_FAILED; - } - result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " - << "PDU1Handler" << std::endl; - return result; - } - - return RETURN_OK; + return RETURN_OK; } void PCDUHandler::initializeSwitchStates() { - switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1; - switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW; - switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN; - switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT; - switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6; - switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B; - switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA; - switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3; - switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS; - switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER; - switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT; - switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; - switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; - switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; - switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; + switchStates[pcduSwitches::Q7S] = pcduSwitches::INIT_STATE_Q7S; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1; + switchStates[pcduSwitches::RW] = pcduSwitches::INIT_STATE_RW; + switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = + pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN; + switchStates[pcduSwitches::SUS_REDUNDANT] = pcduSwitches::INIT_STATE_SUS_REDUNDANT; + switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6; + switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B; + switchStates[pcduSwitches::PAYLOAD_CAMERA] = pcduSwitches::INIT_STATE_PAYLOAD_CAMERA; + switchStates[pcduSwitches::TCS_BOARD_3V3] = pcduSwitches::INIT_STATE_TCS_BOARD_3V3; + switchStates[pcduSwitches::SYRLINKS] = pcduSwitches::INIT_STATE_SYRLINKS; + switchStates[pcduSwitches::STAR_TRACKER] = pcduSwitches::INIT_STATE_STAR_TRACKER; + switchStates[pcduSwitches::MGT] = pcduSwitches::INIT_STATE_MGT; + switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; + switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; + switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; } void PCDUHandler::readCommandQueue() { - ReturnValue_t result; - CommandMessage command; + ReturnValue_t result; + CommandMessage command; - result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } + result = commandQueue->receiveMessage(&command); + if (result != RETURN_OK) { + return; + } - result = poolManager.handleHousekeepingMessage(&command); - if (result == RETURN_OK) { - return; - } + result = poolManager.handleHousekeepingMessage(&command); + if (result == RETURN_OK) { + return; + } } -MessageQueueId_t PCDUHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t PCDUHandler::getCommandQueue() const { return commandQueue->getId(); } void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId) { - - if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) { - updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); - updatePdu2SwitchStates(); - } - else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) { - updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); - updatePdu1SwitchStates(); - } - else { - sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl; - } + if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) { + updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); + updatePdu2SwitchStates(); + } else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) { + updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); + updatePdu1SwitchStates(); + } else { + sif::error << "PCDUHandler::handleChangedDataset: Invalid sid" << std::endl; + } } -void PCDUHandler::updateHkTableDataset(store_address_t storeId, - LocalPoolDataSetBase* dataset, CCSDSTime::CDS_short* datasetTimeStamp) { - ReturnValue_t result; +void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, + CCSDSTime::CDS_short* datasetTimeStamp) { + ReturnValue_t result; - HousekeepingSnapshot packetUpdate(reinterpret_cast(datasetTimeStamp), - sizeof(CCSDSTime::CDS_short), dataset); - const uint8_t* packet_ptr = NULL; - size_t size; - result = IPCStore->getData(storeId, &packet_ptr, &size); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore." - << std::endl; - } - dataset->read(); - result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet " - "in hk table dataset"<< std::endl; - } - dataset->commit(); - result = IPCStore->deleteData(storeId); - if (result != RETURN_OK) { - sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore" - << std::endl; - } + HousekeepingSnapshot packetUpdate(reinterpret_cast(datasetTimeStamp), + sizeof(CCSDSTime::CDS_short), dataset); + const uint8_t* packet_ptr = NULL; + size_t size; + result = IPCStore->getData(storeId, &packet_ptr, &size); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to get data from IPCStore." + << std::endl; + } + dataset->read(); + result = packetUpdate.deSerialize(&packet_ptr, &size, SerializeIF::Endianness::MACHINE); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to deserialize received packet " + "in hk table dataset" + << std::endl; + } + dataset->commit(); + result = IPCStore->deleteData(storeId); + if (result != RETURN_OK) { + sif::error << "PCDUHandler::updateHkTableDataset: Failed to delete data in IPCStore" + << std::endl; + } } void PCDUHandler::updatePdu2SwitchStates() { - //TODO: pool read helper - if (pdu2HkTableDataset.read() == RETURN_OK) { - switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value; - switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value; - switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value; - switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value; - switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = pdu2HkTableDataset.outEnabledDeplMechanism.value; - switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value; - switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value; - switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value; - } - else { - sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset" - << std::endl; - } - pdu2HkTableDataset.commit(); + // TODO: pool read helper + if (pdu2HkTableDataset.read() == RETURN_OK) { + switchStates[pcduSwitches::Q7S] = pdu2HkTableDataset.outEnabledQ7S.value; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH1] = pdu2HkTableDataset.outEnabledPlPCDUCh1.value; + switchStates[pcduSwitches::RW] = pdu2HkTableDataset.outEnabledReactionWheels.value; + switchStates[pcduSwitches::TCS_BOARD_8V_HEATER_IN] = + pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value; + switchStates[pcduSwitches::SUS_REDUNDANT] = pdu2HkTableDataset.outEnabledSUSRedundant.value; + switchStates[pcduSwitches::DEPLOYMENT_MECHANISM] = + pdu2HkTableDataset.outEnabledDeplMechanism.value; + switchStates[pcduSwitches::PAYLOAD_PCDU_CH6] = pdu2HkTableDataset.outEnabledPlPCDUCh6.value; + switchStates[pcduSwitches::ACS_BOARD_SIDE_B] = pdu2HkTableDataset.outEnabledAcsBoardSideB.value; + switchStates[pcduSwitches::PAYLOAD_CAMERA] = pdu2HkTableDataset.outEnabledPayloadCamera.value; + } else { + sif::debug << "PCDUHandler::updatePdu2SwitchStates: Failed to read PDU2 Hk Dataset" + << std::endl; + } + pdu2HkTableDataset.commit(); } void PCDUHandler::updatePdu1SwitchStates() { - if (pdu1HkTableDataset.read() == RETURN_OK) { - switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value; - switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value; - switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value; - switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value; - switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; - switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; - switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; - switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; - } - else { - sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; - } - pdu1HkTableDataset.commit(); + if (pdu1HkTableDataset.read() == RETURN_OK) { + switchStates[pcduSwitches::TCS_BOARD_3V3] = pdu1HkTableDataset.voltageOutTCSBoard3V3.value; + switchStates[pcduSwitches::SYRLINKS] = pdu1HkTableDataset.voltageOutSyrlinks.value; + switchStates[pcduSwitches::STAR_TRACKER] = pdu1HkTableDataset.voltageOutStarTracker.value; + switchStates[pcduSwitches::MGT] = pdu1HkTableDataset.voltageOutMGT.value; + switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; + switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; + switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; + } else { + sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; + } + pdu1HkTableDataset.commit(); } -LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { - return &poolManager; -} +LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { return &poolManager; } void PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const { + ReturnValue_t result; + uint16_t memoryAddress; + size_t parameterValueSize = sizeof(uint8_t); + uint8_t parameterValue; + GomspaceDeviceHandler* pdu; - ReturnValue_t result; - uint16_t memoryAddress; - size_t parameterValueSize = sizeof(uint8_t); - uint8_t parameterValue; - GomspaceDeviceHandler* pdu; - - switch (switchNr) { + switch (switchNr) { case pcduSwitches::TCS_BOARD_8V_HEATER_IN: - memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; - pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); - break; + memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN; + pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); + break; case pcduSwitches::DEPLOYMENT_MECHANISM: - memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; - pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); - break; + memoryAddress = PDU2::CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM; + pdu = ObjectManager::instance()->get(objects::PDU2_HANDLER); + break; default: - sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl; - return; - } + sif::error << "PCDUHandler::sendSwitchCommand: Invalid switch number " << std::endl; + return; + } - switch (onOff) { + switch (onOff) { case PowerSwitchIF::SWITCH_ON: - parameterValue = 1; - break; + parameterValue = 1; + break; case PowerSwitchIF::SWITCH_OFF: - parameterValue = 0; - break; + parameterValue = 0; + break; default: - sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl; - return; - } + sif::error << "PCDUHandler::sendSwitchCommand: Invalid state commanded" << std::endl; + return; + } - GomspaceSetParamMessage setParamMessage(memoryAddress, ¶meterValue, parameterValueSize); + GomspaceSetParamMessage setParamMessage(memoryAddress, ¶meterValue, parameterValueSize); - size_t serializedLength = 0; - uint8_t command[4]; - uint8_t* commandPtr = command; - size_t maxSize = sizeof(command); - setParamMessage.serialize(&commandPtr, &serializedLength, maxSize, - SerializeIF::Endianness::BIG); + size_t serializedLength = 0; + uint8_t command[4]; + uint8_t* commandPtr = command; + size_t maxSize = sizeof(command); + setParamMessage.serialize(&commandPtr, &serializedLength, maxSize, SerializeIF::Endianness::BIG); - store_address_t storeAddress; - result = IPCStore->addData(&storeAddress, command,sizeof(command)); + store_address_t storeAddress; + result = IPCStore->addData(&storeAddress, command, sizeof(command)); - CommandMessage message; - ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress); + CommandMessage message; + ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress); - result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0); - if (result != RETURN_OK) { - sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler" - << std::endl; - } + result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0); + if (result != RETURN_OK) { + sif::debug << "PCDUHandler::sendSwitchCommand: Failed to send message to PDU Handler" + << std::endl; + } } -void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const { +void PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) const {} +ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { + if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { + sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; + return RETURN_FAILED; + } + if (switchStates[switchNr] == 1) { + return PowerSwitchIF::SWITCH_ON; + } else { + return PowerSwitchIF::SWITCH_OFF; + } } -ReturnValue_t PCDUHandler::getSwitchState( uint8_t switchNr ) const { - if (switchNr >= pcduSwitches::NUMBER_OF_SWITCHES) { - sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; - return RETURN_FAILED; - } - if (switchStates[switchNr] == 1) { - return PowerSwitchIF::SWITCH_ON; - } - else { - return PowerSwitchIF::SWITCH_OFF; - } -} +ReturnValue_t PCDUHandler::getFuseState(uint8_t fuseNr) const { return RETURN_OK; } -ReturnValue_t PCDUHandler::getFuseState( uint8_t fuseNr ) const { - return RETURN_OK; -} +uint32_t PCDUHandler::getSwitchDelayMs(void) const { return 20000; } -uint32_t PCDUHandler::getSwitchDelayMs(void) const { - return 20000; -} +object_id_t PCDUHandler::getObjectId() const { return SystemObject::getObjectId(); } -object_id_t PCDUHandler::getObjectId() const { - return SystemObject::getObjectId(); -} +ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); -ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, - new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry( { - pcduSwitches::INIT_STATE_Q7S })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry( { - pcduSwitches::INIT_STATE_RW })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, + new PoolEntry({pcduSwitches::INIT_STATE_Q7S})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH1})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, + new PoolEntry({pcduSwitches::INIT_STATE_RW})); #if BOARD_TE0720 == 1 - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 1 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); #else - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( {pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN})); + localDataPoolMap.emplace( + P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, + new PoolEntry({pcduSwitches::INIT_STATE_TCS_BOARD_8V_HEATER_IN})); #endif - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry( { - pcduSwitches::INIT_STATE_SUS_REDUNDANT })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry( { - pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry( { - pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry( { - pcduSwitches::INIT_STATE_PAYLOAD_CAMERA })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, + new PoolEntry({pcduSwitches::INIT_STATE_SUS_REDUNDANT})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + new PoolEntry({pcduSwitches::INIT_STATE_DEPLOYMENT_MECHANISM})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_PCDU_CH6})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, + new PoolEntry({pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_B})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, + new PoolEntry({pcduSwitches::INIT_STATE_PAYLOAD_CAMERA})); - localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PCDUHandler::initializeAfterTaskCreation() { + if (executingTask != nullptr) { + pstIntervalMs = executingTask->getPeriodMs(); + } + this->poolManager.initializeAfterTaskCreation(); - if(executingTask != nullptr) { - pstIntervalMs = executingTask->getPeriodMs(); - } - this->poolManager.initializeAfterTaskCreation(); + initializeSwitchStates(); - initializeSwitchStates(); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } -uint32_t PCDUHandler::getPeriodicOperationFrequency() const { - return pstIntervalMs; -} +uint32_t PCDUHandler::getPeriodicOperationFrequency() const { return pstIntervalMs; } -void PCDUHandler::setTaskIF(PeriodicTaskIF* task){ - executingTask = task; -} +void PCDUHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; } LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { - if (sid == pdu2HkTableDataset.getSid()) { - return &pdu2HkTableDataset; - } else { - sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == pdu2HkTableDataset.getSid()) { + return &pdu2HkTableDataset; + } else { + sif::error << "PCDUHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } diff --git a/mission/devices/PCDUHandler.h b/mission/devices/PCDUHandler.h index 566e1d9c..c045ed03 100644 --- a/mission/devices/PCDUHandler.h +++ b/mission/devices/PCDUHandler.h @@ -2,120 +2,116 @@ #define MISSION_DEVICES_PCDUHANDLER_H_ #include -#include -#include -#include -#include #include #include +#include #include -#include - +#include +#include +#include /** * @brief The PCDUHandler provides a compact interface to handle all devices related to the - * control of power. This is necessary because the fsfw manages all power related - * functionalities via one power object. This includes for example the switch on and off - * of devices. + * control of power. This is necessary because the fsfw manages all power + * related functionalities via one power object. This includes for example the switch on and off of + * devices. */ -class PCDUHandler: public PowerSwitchIF, - public HasLocalDataPoolIF, - public SystemObject, - public ExecutableObjectIF { -public: +class PCDUHandler : public PowerSwitchIF, + public HasLocalDataPoolIF, + public SystemObject, + public ExecutableObjectIF { + public: + PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); + virtual ~PCDUHandler(); - PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); - virtual ~PCDUHandler(); + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t performOperation(uint8_t counter) override; + virtual void handleChangedDataset(sid_t sid, + store_address_t storeId = storeId::INVALID_STORE_ADDRESS); - virtual ReturnValue_t initialize() override; - virtual ReturnValue_t performOperation(uint8_t counter) override; - virtual void handleChangedDataset(sid_t sid, store_address_t storeId = - storeId::INVALID_STORE_ADDRESS); + virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; + virtual void sendFuseOnCommand(uint8_t fuseNr) const override; + virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; + virtual uint32_t getSwitchDelayMs(void) const override; + virtual object_id_t getObjectId() const override; + virtual LocalDataPoolManager* getHkManagerHandle() override; - virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const override; - virtual void sendFuseOnCommand(uint8_t fuseNr) const override; - virtual ReturnValue_t getSwitchState( uint8_t switchNr ) const override; - virtual ReturnValue_t getFuseState( uint8_t fuseNr ) const override; - virtual uint32_t getSwitchDelayMs(void) const override; - virtual object_id_t getObjectId() const override; - virtual LocalDataPoolManager* getHkManagerHandle() override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + virtual uint32_t getPeriodicOperationFrequency() const override; + virtual ReturnValue_t initializeAfterTaskCreation() override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + virtual void setTaskIF(PeriodicTaskIF* task_); - virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - virtual uint32_t getPeriodicOperationFrequency() const override; - virtual ReturnValue_t initializeAfterTaskCreation() override; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - virtual void setTaskIF(PeriodicTaskIF* task_); + private: + uint32_t pstIntervalMs = 0; -private: + /** Housekeeping manager. Handles updates of local pool variables. */ + LocalDataPoolManager poolManager; - uint32_t pstIntervalMs = 0; + /** + * The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset + * of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent + * to this object via a HousekeepingMessage. + */ + PDU2::PDU2HkTableDataset pdu2HkTableDataset; + /** The timeStamp of the current pdu2HkTableDataset */ + CCSDSTime::CDS_short timeStampPdu2HkDataset; - /** Housekeeping manager. Handles updates of local pool variables. */ - LocalDataPoolManager poolManager; + /** Hk table dataset of PDU1 */ + PDU1::PDU1HkTableDataset pdu1HkTableDataset; + /** The timeStamp of the current pdu1HkTableDataset */ + CCSDSTime::CDS_short timeStampPdu1HkDataset; - /** - * The dataset holding the hk table of PDU2. This dataset is a copy of the PDU2 HK dataset - * of the PDU2Handler. Each time the PDU2Handler updates his HK dataset, a copy is sent - * to this object via a HousekeepingMessage. - */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; - /** The timeStamp of the current pdu2HkTableDataset */ - CCSDSTime::CDS_short timeStampPdu2HkDataset; + uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES]; + /** + * Pointer to the IPCStore. + * This caches the pointer received from the objectManager in the constructor. + */ + StorageManagerIF* IPCStore = nullptr; - /** Hk table dataset of PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; - /** The timeStamp of the current pdu1HkTableDataset */ - CCSDSTime::CDS_short timeStampPdu1HkDataset; + /** + * Message queue to communicate with other objetcs. Used for example to receive + * local pool messages from ACU, PDU1 and PDU2. + */ + MessageQueueIF* commandQueue = nullptr; - uint8_t switchStates[pcduSwitches::NUMBER_OF_SWITCHES]; - /** - * Pointer to the IPCStore. - * This caches the pointer received from the objectManager in the constructor. - */ - StorageManagerIF *IPCStore = nullptr; + size_t cmdQueueSize; - /** - * Message queue to communicate with other objetcs. Used for example to receive - * local pool messages from ACU, PDU1 and PDU2. - */ - MessageQueueIF* commandQueue = nullptr; + PeriodicTaskIF* executingTask = nullptr; - size_t cmdQueueSize; + void readCommandQueue(); - PeriodicTaskIF* executingTask = nullptr; + /** + * @brief This function sets all switchStates to the initial switch configuration of the + * two PDUs after reboot. + */ + void initializeSwitchStates(); - void readCommandQueue(); + /** + * @brief Updates all switchStates related to the PDU2. + * Function is called each time a new hk dataset has been received from the PDU2Handler. + */ + void updatePdu2SwitchStates(); - /** - * @brief This function sets all switchStates to the initial switch configuration of the - * two PDUs after reboot. - */ - void initializeSwitchStates(); + /** + * @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler + * sends a new hk dataset. + */ + void updatePdu1SwitchStates(); - /** - * @brief Updates all switchStates related to the PDU2. - * Function is called each time a new hk dataset has been received from the PDU2Handler. - */ - void updatePdu2SwitchStates(); - - /** - * @brief Updates all switchStates related to the PDU1. Called each time the PDU1Handler - * sends a new hk dataset. - */ - void updatePdu1SwitchStates(); - - /** - * @brief In case of an update snapshot message this function handles the update of the - * local dataset. - * @param storeId Storage id of updated dataset. - * @param dataset Pointer to the local dataset. - * @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated - * dataset. - */ - void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, - CCSDSTime::CDS_short* datasetTimeStamp); + /** + * @brief In case of an update snapshot message this function handles the update of the + * local dataset. + * @param storeId Storage id of updated dataset. + * @param dataset Pointer to the local dataset. + * @param datasetTimeStamp Pointer to a variable which will hold the timestamp of the updated + * dataset. + */ + void updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, + CCSDSTime::CDS_short* datasetTimeStamp); }; #endif /* MISSION_DEVICES_PCDUHANDLER_H_ */ diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index 1676e488..a1486588 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -1,402 +1,421 @@ -#include "OBSWConfig.h" #include "PDU1Handler.h" #include -PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu1HkTableDataset), - pdu1HkTableDataset(this) { -} +#include "OBSWConfig.h" -PDU1Handler::~PDU1Handler() { -} +PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, + &pdu1HkTableDataset), + pdu1HkTableDataset(this) {} -ReturnValue_t PDU1Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +PDU1Handler::~PDU1Handler() {} + +ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - handleDeviceTM(&pdu1HkTableDataset, id, true); + parseHkTableReply(packet); + handleDeviceTM(&pdu1HkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU1 == 1 - pdu1HkTableDataset.read(); - sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 + pdu1HkTableDataset.read(); + sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 << std::endl; + sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker << std::endl; - sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker + sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; + sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal << std::endl; + sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp << std::endl; - sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; - sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal + sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA << std::endl; - sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp - << std::endl; - sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA - << std::endl; - sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA + sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA << std::endl; - sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 + sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 << std::endl; + sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker << std::endl; - sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; - sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker + sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; + sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal << std::endl; + sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp << std::endl; - sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; - sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal + sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA << std::endl; - sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp + sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 << std::endl; + printOutputSwitchStates(); + sif::info << "PDU1 battery mode: " << static_cast(pdu1HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; - sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA + sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; + float vbat = pdu1HkTableDataset.vbat.value * 0.001; + sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; + float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; + sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; + sif::info << "PDU1 csp1 watchdog pings before reboot: " + << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 + sif::info << "PDU1 csp2 watchdog pings before reboot: " + << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - printOutputSwitchStates(); - sif::info << "PDU1 battery mode: " << - static_cast(pdu1HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu1HkTableDataset.vbat.value * 0.001; - sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; - float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; - sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; - sif::info << "PDU1 csp1 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU1 csp2 watchdog pings before reboot: " - << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - pdu1HkTableDataset.commit(); + pdu1HkTableDataset.commit(); #endif } void PDU1Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - PoolReadGuard pg(&pdu1HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return; - } - /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. */ - dataOffset += 12; - pdu1HkTableDataset.currentOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + PoolReadGuard pg(&pdu1HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return; + } + /* Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. */ + dataOffset += 12; + pdu1HkTableDataset.currentOutTCSBoard3V3 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutStarTracker = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSUSNominal = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutACSBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.currentOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.voltageOutTCSBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSUSNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutACSBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.voltageOutTCSBoard3V3 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutStarTracker = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutMGT = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSUSNominal = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutPLOC = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutACSBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.voltageOutChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.converterEnable1 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.converterEnable2 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.converterEnable3 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.outEnabledTCSBoard3V3 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSyrlinks = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledStarTracker = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledMGT = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSUSNominal = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledSolarCellExp = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledPLOC = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledAcsBoardSideA = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.outEnabledChannel8 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu1HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; + pdu1HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); + dataOffset += 4; + pdu1HkTableDataset.battMode = *(packet + dataOffset); + /* +10 because here begins the second gomspace csp packet */ + dataOffset += 3 + 10; - pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsSolarCellExp = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsAcsBoardSideA = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu1HkTableDataset.latchupsTcsBoard3V3 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSyrlinks = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsStarTracker = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsMgt = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSusNominal = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsSolarCellExp = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsPloc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsAcsBoardSideA = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu1HkTableDataset.latchupsChannel8 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu1HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + pdu1HkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); + pdu1HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.groundWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.i2cWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.canWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu1HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); + dataOffset += 3; + pdu1HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - pdu1HkTableDataset.setChanged(true); - if(not pdu1HkTableDataset.isValid()) { - pdu1HkTableDataset.setValidity(true, true); - } + pdu1HkTableDataset.setChanged(true); + if (not pdu1HkTableDataset.isValid()) { + pdu1HkTableDataset.setValidity(true, true); + } } -ReturnValue_t PDU1Handler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CURRENT_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VOLTAGE_OUT_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_CONV_EN_3, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_OUT_EN_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_TCS_BOARD_3V3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SYRLINKS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_STAR_TRACKER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_MGT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SUS_NOMINAL, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_PLOC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_LATCHUP_CHANNEL8, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU1_WDT_CSP_LEFT2, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu1HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&pdu1HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void PDU1Handler::printHkTable() { - sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " << - unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl; - sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " << - unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl; - sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutStarTracker.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutStarTracker.value << std::endl; - sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledMGT.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutMGT.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutMGT.value << std::endl; - sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSUSNominal.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl; - sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutSolarCellExp.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl; - sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutPLOC.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutPLOC.value << std::endl; - sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutACSBoardSideA.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutACSBoardSideA.value << std::endl; - sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " << - static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << ", " << - std::setw(4) << std::right << - pdu1HkTableDataset.currentOutChannel8.value << ", " << std::setw(4) << - pdu1HkTableDataset.voltageOutChannel8.value << std::right << std::endl; + sif::info << "PDU1 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "TCS Board" << std::dec << "| " + << unsigned(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << ", " << std::setw(4) + << std::right << pdu1HkTableDataset.currentOutTCSBoard3V3.value << ", " << std::setw(4) + << pdu1HkTableDataset.voltageOutTCSBoard3V3.value << std::endl; + sif::info << std::setw(30) << std::left << "Syrlinks" << std::dec << "| " + << unsigned(pdu1HkTableDataset.outEnabledSyrlinks.value) << ", " << std::setw(4) + << std::right << pdu1HkTableDataset.currentOutSyrlinks.value << ", " << std::setw(4) + << pdu1HkTableDataset.voltageOutSyrlinks.value << std::endl; + sif::info << std::setw(30) << std::left << "Star Tracker" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutStarTracker.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutStarTracker.value << std::endl; + sif::info << std::setw(30) << std::left << "MGT" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledMGT.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutMGT.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutMGT.value << std::endl; + sif::info << std::setw(30) << std::left << "SuS nominal" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSUSNominal.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutSUSNominal.value << std::endl; + sif::info << std::setw(30) << std::left << "Solar Cell Experiment" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutSolarCellExp.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutSolarCellExp.value << std::endl; + sif::info << std::setw(30) << std::left << "PLOC" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutPLOC.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutPLOC.value << std::endl; + sif::info << std::setw(30) << std::left << "ACS Side A" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutACSBoardSideA.value + << ", " << std::setw(4) << pdu1HkTableDataset.voltageOutACSBoardSideA.value + << std::endl; + sif::info << std::setw(30) << std::left << "Channel 8" << std::dec << "| " + << static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << ", " + << std::setw(4) << std::right << pdu1HkTableDataset.currentOutChannel8.value << ", " + << std::setw(4) << pdu1HkTableDataset.voltageOutChannel8.value << std::right + << std::endl; } - diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 3df99776..0715b078 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -19,27 +19,28 @@ * ACS 3.3V for Side A group, channel 7 * Unoccupied, 5V, channel 8 */ -class PDU1Handler: public GomspaceDeviceHandler { -public: - PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PDU1Handler(); +class PDU1Handler : public GomspaceDeviceHandler { + public: + PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PDU1Handler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; -protected: - /** - * @brief In MODE_NORMAL, a command will be built periodically by this function. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; - ReturnValue_t printStatus(DeviceCommandId_t cmd) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -private: - /** Dataset for the housekeeping table of the PDU1 */ - PDU1::PDU1HkTableDataset pdu1HkTableDataset; + protected: + /** + * @brief In MODE_NORMAL, a command will be built periodically by this function. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; + ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - void printHkTable(); - void parseHkTableReply(const uint8_t *packet); + private: + /** Dataset for the housekeeping table of the PDU1 */ + PDU1::PDU1HkTableDataset pdu1HkTableDataset; + + void printHkTable(); + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_PDU1Handler_H_ */ diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 287fdaf3..b5c34af6 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -1,378 +1,423 @@ -#include "OBSWConfig.h" #include "PDU2Handler.h" -#include #include +#include -PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, &pdu2HkTableDataset), - pdu2HkTableDataset(this) { -} +#include "OBSWConfig.h" -PDU2Handler::~PDU2Handler() { -} +PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE, + &pdu2HkTableDataset), + pdu2HkTableDataset(this) {} -ReturnValue_t PDU2Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - *id = GOMSPACE::REQUEST_HK_TABLE; - return buildCommandFromCommand(*id, NULL, 0); +PDU2Handler::~PDU2Handler() {} + +ReturnValue_t PDU2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + *id = GOMSPACE::REQUEST_HK_TABLE; + return buildCommandFromCommand(*id, NULL, 0); } void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { - - parseHkTableReply(packet); - /** - * Hk table will be sent to the commander if hk table request was not triggered by the - * PDU2Handler itself. - */ - handleDeviceTM(&pdu2HkTableDataset, id, true); + parseHkTableReply(packet); + /** + * Hk table will be sent to the commander if hk table request was not triggered by the + * PDU2Handler itself. + */ + handleDeviceTM(&pdu2HkTableDataset, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU2 == 1 - pdu2HkTableDataset.read(); - sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" << std::endl; - sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu2HkTableDataset.vbat.value * 0.1; - sif::info << "PDU2 VBAT: " << vbat << std::endl; - float temperatureC = pdu2HkTableDataset.temperature.value * 0.1; - sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl; - printOutputSwitchStates(); - sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl; - sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl; - sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl; - sif::info << "PDU2 ground watchdog timer seconds left: " + pdu2HkTableDataset.read(); + sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" + << std::endl; + sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; + float vbat = pdu2HkTableDataset.vbat.value * 0.1; + sif::info << "PDU2 VBAT: " << vbat << std::endl; + float temperatureC = pdu2HkTableDataset.temperature.value * 0.1; + sif::info << "PDU2 Temperature: " << temperatureC << " °C" << std::endl; + printOutputSwitchStates(); + sif::info << "PDU2 uptime: " << pdu2HkTableDataset.uptime << " seconds" << std::endl; + sif::info << "PDU2 battery mode: " << unsigned(pdu2HkTableDataset.battMode.value) << std::endl; + sif::info << "PDU2 ground watchdog reboots: " << pdu2HkTableDataset.gndWdtReboots << std::endl; + sif::info << "PDU2 ground watchdog timer seconds left: " << pdu2HkTableDataset.groundWatchdogSecondsLeft << " seconds" << std::endl; - sif::info << "PDU2 csp1 watchdog pings before reboot: " + sif::info << "PDU2 csp1 watchdog pings before reboot: " << unsigned(pdu2HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; - sif::info << "PDU2 csp2 watchdog pings before reboot: " + sif::info << "PDU2 csp2 watchdog pings before reboot: " << unsigned(pdu2HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; - pdu2HkTableDataset.commit(); + pdu2HkTableDataset.commit(); #endif } void PDU2Handler::parseHkTableReply(const uint8_t *packet) { - uint16_t dataOffset = 0; - pdu2HkTableDataset.read(); - /** - * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table - * address. - */ - dataOffset += 12; - pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.currentOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + uint16_t dataOffset = 0; + pdu2HkTableDataset.read(); + /** + * Fist 10 bytes contain the gomspace header. Each variable is preceded by the 16-bit table + * address. + */ + dataOffset += 12; + pdu2HkTableDataset.currentOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadPCDUCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutReactionWheels = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutTCSBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutSUSRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutDeplMechanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadPCDUCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutACSBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.currentOutPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutReactionWheels = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutSUSRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutDeplMechanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutACSBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.voltageOutPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.voltageOutQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadPCDUCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutReactionWheels = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutTCSBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutSUSRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutDeplMechanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadPCDUCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutACSBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.voltageOutPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.temperature = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.converterEnable1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.converterEnable2 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.converterEnable3 = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.outEnabledQ7S = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPlPCDUCh1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledReactionWheels = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledTCSBoardHeaterIn = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledSUSRedundant = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledDeplMechanism = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPlPCDUCh6 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledAcsBoardSideB = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.outEnabledPayloadCamera = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); - dataOffset += 4; - pdu2HkTableDataset.battMode = *(packet + dataOffset); - /* +10 because here begins the second gomspace csp packet */ - dataOffset += 3 + 10; + pdu2HkTableDataset.bootcause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.bootcount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.resetcause = *(packet + dataOffset + 1) << 8 | *(packet + dataOffset); + dataOffset += 4; + pdu2HkTableDataset.battMode = *(packet + dataOffset); + /* +10 because here begins the second gomspace csp packet */ + dataOffset += 3 + 10; - pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsTcsBoardHeaterIn = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsSusRedundant = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsDeplMenchanism = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadPcduCh6 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsAcsBoardSideB = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; - pdu2HkTableDataset.latchupsPayloadCamera = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); - dataOffset += 4; + pdu2HkTableDataset.latchupsQ7S = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadPcduCh1 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsRw = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsTcsBoardHeaterIn = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsSusRedundant = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsDeplMenchanism = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadPcduCh6 = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsAcsBoardSideB = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; + pdu2HkTableDataset.latchupsPayloadCamera = + *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - pdu2HkTableDataset.device0 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6 = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7 = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.device0 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device1 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device2 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device3 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device4 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device5 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device6 = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device7 = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.device0Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device1Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device2Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device3Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device4Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device5Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device6Status = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.device7Status = *(packet + dataOffset); - dataOffset += 3; + pdu2HkTableDataset.device0Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device1Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device2Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device3Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device4Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device5Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device6Status = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.device7Status = *(packet + dataOffset); + dataOffset += 3; - pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.groundWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.i2cWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.canWatchdogSecondsLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - dataOffset += 6; - pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); - dataOffset += 3; - pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); + pdu2HkTableDataset.gndWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.i2cWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.canWdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp1WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp2WdtReboots = *(packet + dataOffset) << 24 | + *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.groundWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.i2cWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.canWatchdogSecondsLeft = + *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + dataOffset += 6; + pdu2HkTableDataset.csp1WatchdogPingsLeft = *(packet + dataOffset); + dataOffset += 3; + pdu2HkTableDataset.csp2WatchdogPingsLeft = *(packet + dataOffset); - pdu2HkTableDataset.commit(); - pdu2HkTableDataset.setChanged(true); + pdu2HkTableDataset.commit(); + pdu2HkTableDataset.setChanged(true); } -ReturnValue_t PDU2Handler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { +ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_VCC, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_VBAT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_CONV_EN_3, new PoolEntry( { 0 })); - - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_RW, new PoolEntry({0})); #if BOARD_TE0720 == 1 - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 1 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({1})); #else - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, new PoolEntry({0})); #endif - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_RESETCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_BATT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_Q7S, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_RW, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_SUS_REDUNDANT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_0_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_1_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_2_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_3_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_4_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_5_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_6_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_DEVICE_7_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry( { 0 })); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_I2C, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CAN, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CNT_CSP2, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_GND_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_I2C_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); + localDataPoolMap.emplace(P60System::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { - switch(cmd) { - case(GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&pdu2HkTableDataset); - ReturnValue_t readResult = pg.getReadResult(); - if(readResult != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Reading PDU1 HK table failed!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - printHkTable(); - return HasReturnvaluesIF::RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&pdu2HkTableDataset); + ReturnValue_t readResult = pg.getReadResult(); + if (readResult != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + printHkTable(); + return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; - } + return HasReturnvaluesIF::RETURN_FAILED; } + } } void PDU2Handler::printHkTable() { - sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; - sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutQ7S.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl; - sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutReactionWheels.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl; - sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl; - sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl; - sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutDeplMechanism.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value<< std::endl; - sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl; - sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| " << - unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << - std::setw(4) << std::right << - pdu2HkTableDataset.currentOutPayloadCamera.value << ", " << std::setw(4) << - pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right << std::endl; + sif::info << "PDU2 Info: SwitchState, Currents [mA], Voltages [mV]" << std::endl; + sif::info << std::setw(30) << std::left << "Q7S" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledQ7S.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutQ7S.value << ", " << std::setw(4) + << pdu2HkTableDataset.voltageOutQ7S.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload PCDU Channel 1" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh1.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh1.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh1.value << std::endl; + sif::info << std::setw(30) << std::left << "Reaction Wheels" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledReactionWheels.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutReactionWheels.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutReactionWheels.value << std::endl; + sif::info << std::setw(30) << std::left << "TCS Board 8V heater input" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledTCSBoardHeaterIn.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutTCSBoardHeaterIn.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutTCSBoardHeaterIn.value << std::endl; + sif::info << std::setw(30) << std::left << "Redundant SUS group" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledSUSRedundant.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutSUSRedundant.value << ", " << std::setw(4) + << pdu2HkTableDataset.voltageOutSUSRedundant.value << std::endl; + sif::info << std::setw(30) << std::left << "Deployment mechanism" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledDeplMechanism.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutDeplMechanism.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutDeplMechanism.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload PCDU Channel 6" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPlPCDUCh6.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadPCDUCh6.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadPCDUCh6.value << std::endl; + sif::info << std::setw(30) << std::left << "ACS Board Side B" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledAcsBoardSideB.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutACSBoardSideB.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutACSBoardSideB.value << std::endl; + sif::info << std::setw(30) << std::left << "Payload Camera enable state" << std::dec << "| " + << unsigned(pdu2HkTableDataset.outEnabledPayloadCamera.value) << ", " << std::setw(4) + << std::right << pdu2HkTableDataset.currentOutPayloadCamera.value << ", " + << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right + << std::endl; } diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index c44d1267..258b616d 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -1,9 +1,10 @@ #ifndef MISSION_DEVICES_PDU2HANDLER_H_ #define MISSION_DEVICES_PDU2HANDLER_H_ -#include "GomspaceDeviceHandler.h" #include +#include "GomspaceDeviceHandler.h" + /** * @brief This is the device handler for the PDU2. * @@ -18,30 +19,29 @@ * ACS Board (Gyro, MGMs, GPS), 3.3V channel 7 * Payload Camera, 8V, channel 8 */ -class PDU2Handler: public GomspaceDeviceHandler { -public: - PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PDU2Handler(); +class PDU2Handler : public GomspaceDeviceHandler { + public: + PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PDU2Handler(); - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: - /** - * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. - */ - virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; - virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) override; - ReturnValue_t printStatus(DeviceCommandId_t cmd) override; + protected: + /** + * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. + */ + virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; + virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; + ReturnValue_t printStatus(DeviceCommandId_t cmd) override; -private: + private: + /** Dataset for the housekeeping table of the PDU2 */ + PDU2::PDU2HkTableDataset pdu2HkTableDataset; - /** Dataset for the housekeeping table of the PDU2 */ - PDU2::PDU2HkTableDataset pdu2HkTableDataset; + void printHkTable(); - void printHkTable(); - - void parseHkTableReply(const uint8_t *packet); + void parseHkTableReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_PDU2HANDLER_H_ */ diff --git a/mission/devices/PlocMPSoCHandler.cpp b/mission/devices/PlocMPSoCHandler.cpp index dcc81ef7..07b9b0fa 100644 --- a/mission/devices/PlocMPSoCHandler.cpp +++ b/mission/devices/PlocMPSoCHandler.cpp @@ -1,497 +1,473 @@ #include "PlocMPSoCHandler.h" + +#include +#include + #include "OBSWConfig.h" -#include -#include +PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie) { + if (comCookie == NULL) { + sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; + } +} -PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie) { - if (comCookie == NULL) { - sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; +PlocMPSoCHandler::~PlocMPSoCHandler() {} + +void PlocMPSoCHandler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } +} + +void PlocMPSoCHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return RETURN_OK; +} + +ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (PLOC_MPSOC::TC_MEM_WRITE): { + return prepareTcMemWriteCommand(commandData, commandDataLen); } -} - -PlocMPSoCHandler::~PlocMPSoCHandler() { -} - - -void PlocMPSoCHandler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } -} - -void PlocMPSoCHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} - -ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - return RETURN_OK; -} - -ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(PLOC_MPSOC::TC_MEM_WRITE): { - return prepareTcMemWriteCommand(commandData, commandDataLen); - } - case(PLOC_MPSOC::TC_MEM_READ): { - return prepareTcMemReadCommand(commandData, commandDataLen); - } - default: - sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl; - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + case (PLOC_MPSOC::TC_MEM_READ): { + return prepareTcMemReadCommand(commandData, commandDataLen); + } + default: + sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" + << std::endl; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void PlocMPSoCHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE); - this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ); - this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE); + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ); + this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, + PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); } -ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; - uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; + switch (apid) { + case (PLOC_MPSOC::APID_ACK_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; + break; + case (PLOC_MPSOC::APID_ACK_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; + break; + case (PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT): + *foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT; + *foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; + break; + case (PLOC_MPSOC::APID_EXE_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; + break; + case (PLOC_MPSOC::APID_EXE_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; + break; + default: { + sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; + *foundLen = remainingSize; + return INVALID_APID; + } + } - switch(apid) { - case(PLOC_MPSOC::APID_ACK_SUCCESS): - *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; - *foundId = PLOC_MPSOC::ACK_REPORT; - break; - case(PLOC_MPSOC::APID_ACK_FAILURE): - *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; - *foundId = PLOC_MPSOC::ACK_REPORT; - break; - case(PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT): - *foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT; - *foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; - break; - case(PLOC_MPSOC::APID_EXE_SUCCESS): - *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; - *foundId = PLOC_MPSOC::EXE_REPORT; - break; - case(PLOC_MPSOC::APID_EXE_FAILURE): - *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; - *foundId = PLOC_MPSOC::EXE_REPORT; - break; - default: { - sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; - *foundLen = remainingSize; - return INVALID_APID; - } - } + /** + * This should normally never fail. However, this function is also responsible for incrementing + * the packet sequence count why it is called here. + */ + result = checkPacketSequenceCount(start); - /** - * This should normally never fail. However, this function is also responsible for incrementing - * the packet sequence count why it is called here. - */ - result = checkPacketSequenceCount(start); - - return result; + return result; } -ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { +ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; - - switch (id) { + switch (id) { case PLOC_MPSOC::ACK_REPORT: { - result = handleAckReport(packet); - break; + result = handleAckReport(packet); + break; } case (PLOC_MPSOC::TM_MEMORY_READ_REPORT): { - result = handleMemoryReadReport(packet); - break; + result = handleMemoryReadReport(packet); + break; } case (PLOC_MPSOC::EXE_REPORT): { - result = handleExecutionReport(packet); - break; + result = handleExecutionReport(packet); + break; } default: { - sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return result; + return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid(){ +void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - - return HasReturnvaluesIF::RETURN_OK; + LocalDataPoolManager& poolManager) { + return HasReturnvaluesIF::RETURN_OK; } -void PlocMPSoCHandler::setModeNormal() { - mode = MODE_NORMAL; +void PlocMPSoCHandler::setModeNormal() { mode = MODE_NORMAL; } + +ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t* commandData, + size_t commandDataLen) { + const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | + *(commandData + 2) << 8 | *(commandData + 3); + const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 | + *(commandData + 6) << 8 | *(commandData + 7); + packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; + PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); + if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl; + return RETURN_FAILED; + } + memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = tcMemWrite.getFullSize(); + nextReplyId = PLOC_MPSOC::ACK_REPORT; + return RETURN_OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * commandData, - size_t commandDataLen) { - const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 - | *(commandData + 6) << 8 | *(commandData + 7); - packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); - if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl; - return RETURN_FAILED; - } - memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize()); - rawPacket = commandBuffer; - rawPacketLen = tcMemWrite.getFullSize(); - nextReplyId = PLOC_MPSOC::ACK_REPORT; - return RETURN_OK; -} +ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t* commandData, + size_t commandDataLen) { + const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | + *(commandData + 2) << 8 | *(commandData + 3); + packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; + PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); + if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl; + return RETURN_FAILED; + } + memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = tcMemRead.getFullSize(); + nextReplyId = PLOC_MPSOC::ACK_REPORT; -ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t * commandData, - size_t commandDataLen) { - const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 - | *(commandData + 2) << 8 | *(commandData + 3); - packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); - if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl; - return RETURN_FAILED; - } - memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize()); - rawPacket = commandBuffer; - rawPacketLen = tcMemRead.getFullSize(); - nextReplyId = PLOC_MPSOC::ACK_REPORT; - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) { + uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); - uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); + uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); - uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); + if (receivedCrc != recalculatedCrc) { + return CRC_FAILURE; + } - if (receivedCrc != recalculatedCrc) { - return CRC_FAILURE; - } - - return RETURN_OK; + return RETURN_OK; } ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT); + triggerEvent(CRC_FAILURE_EVENT); + sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE); + disableAllReplies(); + return IGNORE_REPLY_DATA; + } - result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC_MPSOC::NONE; - replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT); - triggerEvent(CRC_FAILURE_EVENT); - sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE); - disableAllReplies(); - return IGNORE_REPLY_DATA; + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + switch (apid) { + case PLOC_MPSOC::APID_ACK_FAILURE: { + // TODO: Interpretation of status field in acknowledgment report + sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(ACK_FAILURE, commandId); + } + sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE); + disableAllReplies(); + nextReplyId = PLOC_MPSOC::NONE; + result = IGNORE_REPLY_DATA; + break; } + case PLOC_MPSOC::APID_ACK_SUCCESS: { + setNextReplyId(); + break; + } + default: { + sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl; + result = RETURN_FAILED; + break; + } + } - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch(apid) { - case PLOC_MPSOC::APID_ACK_FAILURE: { - //TODO: Interpretation of status field in acknowledgment report - sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(ACK_FAILURE, commandId); - } - sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE); - disableAllReplies(); - nextReplyId = PLOC_MPSOC::NONE; - result = IGNORE_REPLY_DATA; - break; - } - case PLOC_MPSOC::APID_ACK_SUCCESS: { - setNextReplyId(); - break; - } - default: { - sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl; - result = RETURN_FAILED; - break; - } - } - - return result; + return result; } ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; + return result; + } - result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC_MPSOC::NONE; - return result; - } + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - - switch (apid) { + switch (apid) { case (PLOC_MPSOC::APID_EXE_SUCCESS): { - break; + break; } case (PLOC_MPSOC::APID_EXE_FAILURE): { - //TODO: Interpretation of status field in execution report - sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" - << std::endl; - DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - triggerEvent(EXE_FAILURE, commandId); - } - else { - sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; - } - sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE); - disableExeReportReply(); - result = IGNORE_REPLY_DATA; - break; + // TODO: Interpretation of status field in execution report + sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(EXE_FAILURE, commandId); + } else { + sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; + } + sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE); + disableExeReportReply(); + result = IGNORE_REPLY_DATA; + break; } default: { - sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl; - result = RETURN_FAILED; - break; - } + sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl; + result = RETURN_FAILED; + break; } + } - nextReplyId = PLOC_MPSOC::NONE; + nextReplyId = PLOC_MPSOC::NONE; - return result; + return result; } ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); - result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); + if (result == CRC_FAILURE) { + sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc" + << std::endl; + } + /** Send data to commanding queue */ + handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA, + PLOC_MPSOC::TM_MEMORY_READ_REPORT); - if(result == CRC_FAILURE) { - sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc" - << std::endl; - } - /** Send data to commanding queue */ - handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA, - PLOC_MPSOC::TM_MEMORY_READ_REPORT); + nextReplyId = PLOC_MPSOC::EXE_REPORT; - nextReplyId = PLOC_MPSOC::EXE_REPORT; - - return result; + return result; } ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies, bool useAlternateId, - DeviceCommandId_t alternateReplyID) { + uint8_t expectedReplies, bool useAlternateId, + DeviceCommandId_t alternateReplyID) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + uint8_t enabledReplies = 0; - uint8_t enabledReplies = 0; - - switch (command->first) { + switch (command->first) { case PLOC_MPSOC::TC_MEM_WRITE: - enabledReplies = 2; - break; + enabledReplies = 2; + break; case PLOC_MPSOC::TC_MEM_READ: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_MPSOC::TM_MEMORY_READ_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " - << PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; - } - break; + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::TM_MEMORY_READ_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; + } + break; } default: - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl; - break; - } + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + break; + } - /** - * 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_MPSOC::ACK_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::ACK_REPORT - << " not in replyMap" << std::endl; - } + /** + * 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_MPSOC::ACK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::ACK_REPORT << " not in replyMap" << std::endl; + } - result = DeviceHandlerBase::enableReplyInReplyMap(command, - enabledReplies, true, PLOC_MPSOC::EXE_REPORT); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::EXE_REPORT - << " not in replyMap" << std::endl; - } + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_MPSOC::EXE_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::EXE_REPORT << " not in replyMap" << std::endl; + } - return RETURN_OK; + return RETURN_OK; } void PlocMPSoCHandler::setNextReplyId() { - switch(getPendingCommand()) { + switch (getPendingCommand()) { case PLOC_MPSOC::TC_MEM_READ: - nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; - break; + nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; + break; default: - /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC_MPSOC::EXE_REPORT; - break; - } + /* If no telemetry is expected the next reply is always the execution report */ + nextReplyId = PLOC_MPSOC::EXE_REPORT; + break; + } } -size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){ - - size_t replyLen = 0; - - if (nextReplyId == PLOC_MPSOC::NONE) { - return replyLen; - } - - DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); - if (iter != deviceReplyMap.end()) { - if (iter->second.delayCycles == 0) { - /* Reply inactive */ - return replyLen; - } - replyLen = iter->second.replyLen; - } - else { - sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id " - << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; - } +size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { + size_t replyLen = 0; + if (nextReplyId == PLOC_MPSOC::NONE) { return replyLen; + } + + DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles == 0) { + /* Reply inactive */ + return replyLen; + } + replyLen = iter->second.replyLen; + } else { + sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id " + << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; + } + + return replyLen; } -void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { +void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, + DeviceCommandId_t replyId) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } - if (wiretappingMode == RAW) { - /* Data already sent in doGetRead() */ - return; - } + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl; - return; - } - MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + if (queueId == NO_COMMANDER) { + return; + } - if (queueId == NO_COMMANDER) { - return; - } - - result = actionHelper.reportData(queueId, replyId, data, dataSize); - if (result != RETURN_OK) { - sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl; - } + result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl; + } } void PlocMPSoCHandler::disableAllReplies() { + DeviceReplyMap::iterator iter; - DeviceReplyMap::iterator iter; + /* Disable ack reply */ + iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); - /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); + DeviceCommandId_t commandId = getPendingCommand(); - DeviceCommandId_t commandId = getPendingCommand(); - - /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ - switch (commandId) { + /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ + switch (commandId) { case PLOC_MPSOC::TC_MEM_WRITE: - break; + break; case PLOC_MPSOC::TC_MEM_READ: { - iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT); - info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - break; + iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT); + info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + break; } default: { - sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId - << std::endl; - break; - } + sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId + << std::endl; + break; } + } - /* We must always disable the execution report reply here */ - disableExeReportReply(); + /* We must always disable the execution report reply here */ + disableExeReportReply(); } void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { + DeviceReplyIter iter = deviceReplyMap.find(replyId); - DeviceReplyIter iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; + return; + } - if (iter == deviceReplyMap.end()) { - sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; - return; - } + DeviceCommandInfo* info = &(iter->second.command->second); - DeviceCommandInfo* info = &(iter->second.command->second); + if (info == nullptr) { + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl; + return; + } - if (info == nullptr) { - sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl; - return; - } - - if (info->sendReplyTo != NO_COMMANDER) { - actionHelper.finish(false, info->sendReplyTo, iter->first, status); - } - info->isExecuting = false; + if (info->sendReplyTo != NO_COMMANDER) { + actionHelper.finish(false, info->sendReplyTo, iter->first, status); + } + info->isExecuting = false; } void PlocMPSoCHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT); - DeviceReplyInfo *info = &(iter->second); - info->delayCycles = 0; - info->command = deviceCommandMap.end(); - /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ - info->command->second.expectedReplies = 0; + DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT); + DeviceReplyInfo* info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ + info->command->second.expectedReplies = 0; } ReturnValue_t PlocMPSoCHandler::checkPacketSequenceCount(const uint8_t* data) { - uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK; - uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK); - if (receivedSequenceCount != expectedPacketSequenceCount) { - sif::debug - << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. " - << std::endl; - sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence " - << "count: " << expectedPacketSequenceCount << std::endl; - } - packetSequenceCount = receivedSequenceCount; - return RETURN_OK; + uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK; + uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK); + if (receivedSequenceCount != expectedPacketSequenceCount) { + sif::debug << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. " + << std::endl; + sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence " + << "count: " << expectedPacketSequenceCount << std::endl; + } + packetSequenceCount = receivedSequenceCount; + return RETURN_OK; } diff --git a/mission/devices/PlocMPSoCHandler.h b/mission/devices/PlocMPSoCHandler.h index 2b3f6a57..2b14424f 100644 --- a/mission/devices/PlocMPSoCHandler.h +++ b/mission/devices/PlocMPSoCHandler.h @@ -3,6 +3,7 @@ #include #include + #include /** @@ -18,189 +19,194 @@ * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * @author J. Meier */ -class PlocMPSoCHandler: public DeviceHandlerBase { -public: +class PlocMPSoCHandler : public DeviceHandlerBase { + public: + PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~PlocMPSoCHandler(); - PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PlocMPSoCHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + protected: + void doStartUp() override; + void doShutDown() override; + 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; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, + uint8_t expectedReplies = 1, bool useAlternateId = false, + DeviceCommandId_t alternateReplyID = 0) override; + size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; -protected: - void doStartUp() override; - void doShutDown() override; - 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; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, - uint8_t expectedReplies = 1, bool useAlternateId = false, - DeviceCommandId_t alternateReplyID = 0) override; - size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER; -private: + static const ReturnValue_t CRC_FAILURE = + MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC + static const ReturnValue_t RECEIVED_ACK_FAILURE = + MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC + static const ReturnValue_t RECEIVED_EXE_FAILURE = + MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC + static const ReturnValue_t INVALID_APID = + MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC - static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC - static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC - static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC + static const Event MEMORY_READ_RPT_CRC_FAILURE = + MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet + static const Event ACK_FAILURE = + MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report + static const Event EXE_FAILURE = + MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report + static const Event CRC_FAILURE_EVENT = + MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; + static const uint16_t APID_MASK = 0x7FF; + static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; - static const Event MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet - static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report - static const Event EXE_FAILURE = MAKE_EVENT(3, severity::LOW); //!> PLOC receive execution failure report - static const Event CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc + uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE]; - static const uint16_t APID_MASK = 0x7FF; - static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; + /** + * @brief This object is incremented each time a packet is sent or received. By checking the + * packet sequence count of a received packet, no packets can be lost without noticing + * it. Only the least significant 14 bits represent the packet sequence count in a + * space packet. Thus the maximum value amounts to 16383 (0x3FFF). + * @note Normally this should never happen because the PLOC replies are always sent in a + * fixed order. However, the PLOC software checks this value and will return an ACK + * failure report in case the sequence count is not incremented with each transferred + * space packet. + */ + uint16_t packetSequenceCount = 0x3FFF; - uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE]; + /** + * This variable is used to store the id of the next reply to receive. This is necessary + * because the PLOC sends as reply to each command at least one acknowledgment and execution + * report. + */ + DeviceCommandId_t nextReplyId = PLOC_MPSOC::NONE; - /** - * @brief This object is incremented each time a packet is sent or received. By checking the - * packet sequence count of a received packet, no packets can be lost without noticing - * it. Only the least significant 14 bits represent the packet sequence count in a - * space packet. Thus the maximum value amounts to 16383 (0x3FFF). - * @note Normally this should never happen because the PLOC replies are always sent in a - * fixed order. However, the PLOC software checks this value and will return an ACK - * failure report in case the sequence count is not incremented with each transferred - * space packet. - */ - uint16_t packetSequenceCount = 0x3FFF; + /** + * @brief This function fills the commandBuffer to initiate the write memory command. + * + * @param commandData Pointer to action command data. + * @param commanDataLen Size of command data in bytes. + * + * @return RETURN_OK if successful, else RETURN_FAILURE. + */ + ReturnValue_t prepareTcMemWriteCommand(const uint8_t* commandData, size_t commandDataLen); - /** - * This variable is used to store the id of the next reply to receive. This is necessary - * because the PLOC sends as reply to each command at least one acknowledgment and execution - * report. - */ - DeviceCommandId_t nextReplyId = PLOC_MPSOC::NONE; + /** + * @brief This function fills the commandBuffer to initiate the write reads command. + * + * @param commandData Pointer to action command data. + * @param commanDataLen Size of command data in bytes. + * + * @return RETURN_OK if successful, else RETURN_FAILURE. + */ + ReturnValue_t prepareTcMemReadCommand(const uint8_t* commandData, size_t commandDataLen); - /** - * @brief This function fills the commandBuffer to initiate the write memory command. - * - * @param commandData Pointer to action command data. - * @param commanDataLen Size of command data in bytes. - * - * @return RETURN_OK if successful, else RETURN_FAILURE. - */ - ReturnValue_t prepareTcMemWriteCommand(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function checks the crc of the received PLOC reply. + * + * @param start Pointer to the first byte of the reply. + * @param foundLen Pointer to the length of the whole packet. + * + * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. + */ + ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); - /** - * @brief This function fills the commandBuffer to initiate the write reads command. - * - * @param commandData Pointer to action command data. - * @param commanDataLen Size of command data in bytes. - * - * @return RETURN_OK if successful, else RETURN_FAILURE. - */ - ReturnValue_t prepareTcMemReadCommand(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function handles the acknowledgment report. + * + * @param data Pointer to the data holding the acknowledgment report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleAckReport(const uint8_t* data); - /** - * @brief This function checks the crc of the received PLOC reply. - * - * @param start Pointer to the first byte of the reply. - * @param foundLen Pointer to the length of the whole packet. - * - * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. - */ - ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); + /** + * @brief This function handles the data of a execution report. + * + * @param data Pointer to the received data packet. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleExecutionReport(const uint8_t* data); - /** - * @brief This function handles the acknowledgment report. - * - * @param data Pointer to the data holding the acknowledgment report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleAckReport(const uint8_t* data); + /** + * @brief This function handles the memory read report. + * + * @param data Pointer to the data buffer holding the memory read report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleMemoryReadReport(const uint8_t* data); - /** - * @brief This function handles the data of a execution report. - * - * @param data Pointer to the received data packet. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleExecutionReport(const uint8_t* data); + /** + * @brief Depending on the current active command, this function sets the reply id of the + * next reply after a successful acknowledgment report has been received. This is + * required by the function getNextReplyLength() to identify the length of the next + * reply to read. + */ + void setNextReplyId(); - /** - * @brief This function handles the memory read report. - * - * @param data Pointer to the data buffer holding the memory read report. - * - * @return RETURN_OK if successful, otherwise an error code. - */ - ReturnValue_t handleMemoryReadReport(const uint8_t* data); + /** + * @brief This function handles action message replies in case the telemetry has been + * requested by another object. + * + * @param data Pointer to the telemetry data. + * @param dataSize Size of telemetry in bytes. + * @param replyId Id of the reply. This will be added to the ActionMessage. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); - /** - * @brief Depending on the current active command, this function sets the reply id of the - * next reply after a successful acknowledgment report has been received. This is - * required by the function getNextReplyLength() to identify the length of the next - * reply to read. - */ - void setNextReplyId(); + /** + * @brief In case an acknowledgment failure reply has been received this function disables + * all previously enabled commands and resets the exepected replies variable of an + * active command. + */ + void disableAllReplies(); - /** - * @brief This function handles action message replies in case the telemetry has been - * requested by another object. - * - * @param data Pointer to the telemetry data. - * @param dataSize Size of telemetry in bytes. - * @param replyId Id of the reply. This will be added to the ActionMessage. - */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + /** + * @brief This function sends a failure report if the active action was commanded by an other + * object. + * + * @param replyId The id of the reply which signals a failure. + * @param status A status byte which gives information about the failure type. + */ + void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - /** - * @brief In case an acknowledgment failure reply has been received this function disables - * all previously enabled commands and resets the exepected replies variable of an - * active command. - */ - void disableAllReplies(); + /** + * @brief This function disables the execution report reply. Within this function also the + * the variable expectedReplies of an active command will be set to 0. + */ + void disableExeReportReply(); - /** - * @brief This function sends a failure report if the active action was commanded by an other - * object. - * - * @param replyId The id of the reply which signals a failure. - * @param status A status byte which gives information about the failure type. - */ - void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); - - /** - * @brief This function disables the execution report reply. Within this function also the - * the variable expectedReplies of an active command will be set to 0. - */ - void disableExeReportReply(); - - /** - * @brief This function checks and increments the packet sequence count of a received space - * packet. - * - * @param data Pointer to a space packet. - * - * @return RETURN_OK if successful - * - * @details There should be never a case in which a wrong packet sequence count is received - * because the communication scheme between PLOC and OBC always follows a strict - * procedure. Thus this function mainly serves for debugging purposes to detected an - * invalid handling of the packet sequence count. - */ - ReturnValue_t checkPacketSequenceCount(const uint8_t* data); + /** + * @brief This function checks and increments the packet sequence count of a received space + * packet. + * + * @param data Pointer to a space packet. + * + * @return RETURN_OK if successful + * + * @details There should be never a case in which a wrong packet sequence count is received + * because the communication scheme between PLOC and OBC always follows a strict + * procedure. Thus this function mainly serves for debugging purposes to detected an + * invalid handling of the packet sequence count. + */ + ReturnValue_t checkPacketSequenceCount(const uint8_t* data); }; #endif /* MISSION_DEVICES_PLOCMPSOCHANDLER_H_ */ diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index 95f045d8..83720b53 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -1,196 +1,177 @@ +#include #include #include -#include RadiationSensorHandler::RadiationSensorHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), dataset( - this) { - if (comCookie == NULL) { - sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl; - } + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) { + if (comCookie == NULL) { + sif::error << "RadiationSensorHandler: Invalid com cookie" << std::endl; + } } -RadiationSensorHandler::~RadiationSensorHandler() { -} +RadiationSensorHandler::~RadiationSensorHandler() {} - -void RadiationSensorHandler::doStartUp(){ - if (internalState == InternalState::CONFIGURED) { +void RadiationSensorHandler::doStartUp() { + if (internalState == InternalState::CONFIGURED) { #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif - } + } } -void RadiationSensorHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} +void RadiationSensorHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - switch (communicationStep) { +ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + switch (communicationStep) { case CommunicationStep::START_CONVERSION: { - *id = RAD_SENSOR::START_CONVERSION; - communicationStep = CommunicationStep::READ_CONVERSIONS; - break; + *id = RAD_SENSOR::START_CONVERSION; + communicationStep = CommunicationStep::READ_CONVERSIONS; + break; } case CommunicationStep::READ_CONVERSIONS: { - *id = RAD_SENSOR::READ_CONVERSIONS; - communicationStep = CommunicationStep::START_CONVERSION; - break; + *id = RAD_SENSOR::READ_CONVERSIONS; + communicationStep = CommunicationStep::START_CONVERSION; + break; } default: { - sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication " - << "step" << std::endl; - return HasReturnvaluesIF::RETURN_OK; + sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication " + << "step" << std::endl; + return HasReturnvaluesIF::RETURN_OK; } - } - return buildCommandFromCommand(*id, nullptr, 0); + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - if (internalState == InternalState::SETUP) { - *id = RAD_SENSOR::WRITE_SETUP; - } - else { - return NOTHING_TO_SEND; - } - return buildCommandFromCommand(*id, nullptr, 0); +ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + if (internalState == InternalState::SETUP) { + *id = RAD_SENSOR::WRITE_SETUP; + } else { + return NOTHING_TO_SEND; + } + return buildCommandFromCommand(*id, nullptr, 0); } -ReturnValue_t RadiationSensorHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(RAD_SENSOR::WRITE_SETUP): { - cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION; - rawPacket = cmdBuffer; - rawPacketLen = 1; - internalState = InternalState::CONFIGURED; - return RETURN_OK; +ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (RAD_SENSOR::WRITE_SETUP): { + cmdBuffer[0] = RAD_SENSOR::SETUP_DEFINITION; + rawPacket = cmdBuffer; + rawPacketLen = 1; + internalState = InternalState::CONFIGURED; + return RETURN_OK; } - case(RAD_SENSOR::START_CONVERSION): { - /* First the fifo will be reset here */ - cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; - cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; - rawPacket = cmdBuffer; - rawPacketLen = 2; - return RETURN_OK; + case (RAD_SENSOR::START_CONVERSION): { + /* First the fifo will be reset here */ + cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; + cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; + rawPacket = cmdBuffer; + rawPacketLen = 2; + return RETURN_OK; } - case(RAD_SENSOR::READ_CONVERSIONS): { - cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE; - std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE); - rawPacket = cmdBuffer; - rawPacketLen = RAD_SENSOR::READ_SIZE; - return RETURN_OK; + case (RAD_SENSOR::READ_CONVERSIONS): { + cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE; + std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE); + rawPacket = cmdBuffer; + rawPacketLen = RAD_SENSOR::READ_SIZE; + return RETURN_OK; } -// case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): { -// /* First the fifo will be reset here */ -// cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; -// cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; -// rawPacket = cmdBuffer; -// rawPacketLen = 2; -// return RETURN_OK; -// } + // case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): { + // /* First the fifo will be reset here */ + // cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; + // cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; + // rawPacket = cmdBuffer; + // rawPacketLen = 2; + // return RETURN_OK; + // } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void RadiationSensorHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP); - this->insertInCommandMap(RAD_SENSOR::START_CONVERSION); - this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset, - RAD_SENSOR::READ_SIZE); + this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP); + this->insertInCommandMap(RAD_SENSOR::START_CONVERSION); + this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset, + RAD_SENSOR::READ_SIZE); } -ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - *foundId = this->getPendingCommand(); +ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + *foundId = this->getPendingCommand(); - switch (*foundId) { + switch (*foundId) { case RAD_SENSOR::START_CONVERSION: case RAD_SENSOR::WRITE_SETUP: - return IGNORE_REPLY_DATA; + return IGNORE_REPLY_DATA; default: - break; - } + break; + } - *foundLen = remainingSize; + *foundLen = remainingSize; - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { + const uint8_t *packet) { + switch (id) { case RAD_SENSOR::READ_CONVERSIONS: { - uint8_t offset = 0; - PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; - offset += 2; - dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset +1)); - offset += 2; - dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 6; - dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); - offset += 2; - dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); + uint8_t offset = 0; + PoolReadGuard readSet(&dataset); + dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; + offset += 2; + dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 6; + dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RAD_SENSOR - sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" - << std::endl; - sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 - << std::endl; - sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 - << std::endl; - sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 - << std::endl; - sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 - << std::endl; - sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 - << std::endl; - sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 + sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" << std::endl; + sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 << std::endl; + sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 << std::endl; + sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 << std::endl; + sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 << std::endl; + sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 << std::endl; + sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 << std::endl; #endif - break; + break; } default: { - sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + sif::debug << "RadiationSensorHandler::interpretDeviceReply: Unknown reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } - - } - return HasReturnvaluesIF::RETURN_OK; + } + return HasReturnvaluesIF::RETURN_OK; } -void RadiationSensorHandler::setNormalDatapoolEntriesInvalid(){ +void RadiationSensorHandler::setNormalDatapoolEntriesInvalid() {} +uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 5000; } -uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 5000; +ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry({0.0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry({0})); + localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry({0})); + return HasReturnvaluesIF::RETURN_OK; } - -ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry( { 0.0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry( { 0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/mission/devices/RadiationSensorHandler.h b/mission/devices/RadiationSensorHandler.h index 5612a1e0..fe4e4264 100644 --- a/mission/devices/RadiationSensorHandler.h +++ b/mission/devices/RadiationSensorHandler.h @@ -5,56 +5,46 @@ #include /** - * @brief This is the device handler class for radiation sensor on the OBC IF Board. The sensor - * is based on the MAX1227 ADC converter. + * @brief This is the device handler class for radiation sensor on the OBC IF Board. The + * sensor is based on the MAX1227 ADC converter. * * @details Datasheet of MAX1227: https://datasheets.maximintegrated.com/en/ds/MAX1227-MAX1231.pdf * * @author J. Meier */ -class RadiationSensorHandler: public DeviceHandlerBase { -public: +class RadiationSensorHandler : public DeviceHandlerBase { + public: + RadiationSensorHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~RadiationSensorHandler(); - RadiationSensorHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~RadiationSensorHandler(); + protected: + void doStartUp() override; + void doShutDown() override; + 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; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; -protected: - void doStartUp() override; - void doShutDown() override; - 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; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + private: + enum class CommunicationStep { START_CONVERSION, READ_CONVERSIONS }; -private: + enum class InternalState { SETUP, CONFIGURED }; - enum class CommunicationStep { - START_CONVERSION, - READ_CONVERSIONS - }; + RAD_SENSOR::RadSensorDataset dataset; - enum class InternalState { - SETUP, - CONFIGURED - }; + static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; - RAD_SENSOR::RadSensorDataset dataset; - - static const uint8_t MAX_CMD_LEN = RAD_SENSOR::READ_SIZE; - - uint8_t cmdBuffer[MAX_CMD_LEN]; - InternalState internalState = InternalState::SETUP; - CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; + uint8_t cmdBuffer[MAX_CMD_LEN]; + InternalState internalState = InternalState::SETUP; + CommunicationStep communicationStep = CommunicationStep::START_CONVERSION; }; #endif /* MISSION_DEVICES_RADIATIONSENSORHANDLER_H_ */ diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index c848c809..f3cd0737 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -1,526 +1,523 @@ #include "RwHandler.h" + +#include +#include + #include "OBSWConfig.h" -#include -#include - -RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) : - DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio), - temperatureSet(this), statusSet(this), lastResetStatusSet(this), tmDataset(this) { - if (comCookie == NULL) { - sif::error << "RwHandler: Invalid com cookie" << std::endl; - } - if (gpioComIF == NULL) { - sif::error << "RwHandler: Invalid gpio communication interface" << std::endl; - } +RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) + : DeviceHandlerBase(objectId, comIF, comCookie), + gpioComIF(gpioComIF), + enableGpio(enableGpio), + temperatureSet(this), + statusSet(this), + lastResetStatusSet(this), + tmDataset(this) { + if (comCookie == NULL) { + sif::error << "RwHandler: Invalid com cookie" << std::endl; + } + if (gpioComIF == NULL) { + sif::error << "RwHandler: Invalid gpio communication interface" << std::endl; + } } -RwHandler::~RwHandler() { -} +RwHandler::~RwHandler() {} void RwHandler::doStartUp() { + internalState = InternalState::GET_RESET_STATUS; - internalState = InternalState::GET_RESET_STATUS; - - if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; - } + if (gpioComIF->pullHigh(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; + } #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); + setMode(MODE_NORMAL); #else - setMode(_MODE_TO_ON); + setMode(_MODE_TO_ON); #endif } void RwHandler::doShutDown() { - if(gpioComIF->pullLow(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; - } - setMode(_MODE_POWER_DOWN); + if (gpioComIF->pullLow(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; + } + setMode(_MODE_POWER_DOWN); } -ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (internalState) { +ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (internalState) { case InternalState::GET_RESET_STATUS: - *id = RwDefinitions::GET_LAST_RESET_STATUS; - internalState = InternalState::READ_TEMPERATURE; - break; + *id = RwDefinitions::GET_LAST_RESET_STATUS; + internalState = InternalState::READ_TEMPERATURE; + break; case InternalState::CLEAR_RESET_STATUS: - *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; - /** After reset status is cleared, reset status will be polled again for verification */ - internalState = InternalState::GET_RESET_STATUS; - break; + *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; + /** After reset status is cleared, reset status will be polled again for verification */ + internalState = InternalState::GET_RESET_STATUS; + break; case InternalState::READ_TEMPERATURE: - *id = RwDefinitions::GET_TEMPERATURE; - internalState = InternalState::GET_RW_SATUS; - break; + *id = RwDefinitions::GET_TEMPERATURE; + internalState = InternalState::GET_RW_SATUS; + break; case InternalState::GET_RW_SATUS: - *id = RwDefinitions::GET_RW_STATUS; - internalState = InternalState::GET_RESET_STATUS; - break; + *id = RwDefinitions::GET_RW_STATUS; + internalState = InternalState::GET_RESET_STATUS; + break; default: - sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); + sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid internal step" << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); } -ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return NOTHING_TO_SEND; +ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return NOTHING_TO_SEND; } ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t * commandData, size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; + const uint8_t* commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; - switch (deviceCommand) { + switch (deviceCommand) { case (RwDefinitions::RESET_MCU): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_LAST_RESET_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_RW_STATUS): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::INIT_RW_CONTROLLER): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::SET_SPEED): { - if (commandDataLen != 6) { - sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" - << " invalid length" << std::endl; - return SET_SPEED_COMMAND_INVALID_LENGTH; - } - result = checkSpeedAndRampTime(commandData, commandDataLen); - if (result != RETURN_OK) { - return result; - } - prepareSetSpeedCmd(commandData, commandDataLen); + if (commandDataLen != 6) { + sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" + << " invalid length" << std::endl; + return SET_SPEED_COMMAND_INVALID_LENGTH; + } + result = checkSpeedAndRampTime(commandData, commandDataLen); + if (result != RETURN_OK) { return result; + } + prepareSetSpeedCmd(commandData, commandDataLen); + return result; } case (RwDefinitions::GET_TEMPERATURE): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } case (RwDefinitions::GET_TM): { - prepareSimpleCommand(deviceCommand); - return RETURN_OK; + prepareSimpleCommand(deviceCommand); + return RETURN_OK; } default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void RwHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RwDefinitions::RESET_MCU); - this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, - RwDefinitions::SIZE_GET_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, - RwDefinitions::SIZE_CLEAR_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, - RwDefinitions::SIZE_GET_RW_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, - RwDefinitions::SIZE_INIT_RW); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, - RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, - RwDefinitions::SIZE_SET_SPEED_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, - RwDefinitions::SIZE_GET_TELEMETRY_REPLY); + this->insertInCommandMap(RwDefinitions::RESET_MCU); + this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, + RwDefinitions::SIZE_GET_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, + RwDefinitions::SIZE_CLEAR_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, + RwDefinitions::SIZE_GET_RW_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, + RwDefinitions::SIZE_INIT_RW); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, + RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, + RwDefinitions::SIZE_SET_SPEED_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, + RwDefinitions::SIZE_GET_TELEMETRY_REPLY); } -ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize, - DeviceCommandId_t *foundId, size_t *foundLen) { - uint8_t replyByte = *start; - switch (replyByte) { +ReturnValue_t RwHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + uint8_t replyByte = *start; + switch (replyByte) { case (RwDefinitions::GET_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; - *foundId = RwDefinitions::GET_LAST_RESET_STATUS; - break; + *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; + *foundId = RwDefinitions::GET_LAST_RESET_STATUS; + break; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; - *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; - break; + *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; + *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; + break; } case (RwDefinitions::GET_RW_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; - *foundId = RwDefinitions::GET_RW_STATUS; - break; + *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; + *foundId = RwDefinitions::GET_RW_STATUS; + break; } case (RwDefinitions::INIT_RW_CONTROLLER): { - *foundLen = RwDefinitions::SIZE_INIT_RW; - *foundId = RwDefinitions::INIT_RW_CONTROLLER; - break; + *foundLen = RwDefinitions::SIZE_INIT_RW; + *foundId = RwDefinitions::INIT_RW_CONTROLLER; + break; } case (RwDefinitions::SET_SPEED): { - *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; - *foundId = RwDefinitions::SET_SPEED; - break; + *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; + *foundId = RwDefinitions::SET_SPEED; + break; } case (RwDefinitions::GET_TEMPERATURE): { - *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; - *foundId = RwDefinitions::GET_TEMPERATURE; - break; + *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; + *foundId = RwDefinitions::GET_TEMPERATURE; + break; } case (RwDefinitions::GET_TM): { - *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; - *foundId = RwDefinitions::GET_TM; - break; + *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; + *foundId = RwDefinitions::GET_TM; + break; } default: { - sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" << - std::endl; - *foundLen = remainingSize; - return RETURN_FAILED; - } + sif::warning << "RwHandler::scanForReply: Reply contains invalid command code" << std::endl; + *foundLen = remainingSize; + return RETURN_FAILED; } + } - sizeOfReply = *foundLen; + sizeOfReply = *foundLen; - return RETURN_OK; + return RETURN_OK; } -ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + /** Check result code */ + if (*(packet + 1) == RwDefinitions::STATE_ERROR) { + sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " << id + << std::endl; + return EXECUTION_FAILED; + } - /** Check result code */ - if (*(packet + 1) == RwDefinitions::STATE_ERROR) { - sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " - << id << std::endl; - return EXECUTION_FAILED; - } + /** Received in little endian byte order */ + uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2); - /** Received in little endian byte order */ - uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2) ; + if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) { + sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl; + return CRC_ERROR; + } - if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) { - sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl; - return CRC_ERROR; - } - - switch (id) { + switch (id) { case (RwDefinitions::GET_LAST_RESET_STATUS): { - handleResetStatusReply(packet); - break; + handleResetStatusReply(packet); + break; } case (RwDefinitions::GET_RW_STATUS): { - handleGetRwStatusReply(packet); - break; + handleGetRwStatusReply(packet); + break; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): case (RwDefinitions::INIT_RW_CONTROLLER): case (RwDefinitions::SET_SPEED): - // no reply data expected - break; + // no reply data expected + break; case (RwDefinitions::GET_TEMPERATURE): { - handleTemperatureReply(packet); - break; + handleTemperatureReply(packet); + break; } case (RwDefinitions::GET_TM): { - handleGetTelemetryReply(packet); - break; + handleGetTelemetryReply(packet); + break; } default: { - sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } + sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } + } - return RETURN_OK; + return RETURN_OK; } -void RwHandler::setNormalDatapoolEntriesInvalid() { +void RwHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; -} +uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry( { 0 })); - - return RETURN_OK; + return RETURN_OK; } void RwHandler::prepareSimpleCommand(DeviceCommandId_t id) { - commandBuffer[0] = static_cast(id); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; + commandBuffer[0] = static_cast(id); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; } ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen) { - int32_t speed = *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 - | *(commandData + 3); + int32_t speed = + *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); - if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { - sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; - return INVALID_SPEED; - } + if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; + return INVALID_SPEED; + } - uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); + uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); - if (rampTime < 10 || rampTime > 10000) { - sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" - << std::endl; - return INVALID_RAMP_TIME; - } + if (rampTime < 10 || rampTime > 10000) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" << std::endl; + return INVALID_RAMP_TIME; + } - return RETURN_OK; + return RETURN_OK; } -void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { - commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); +void RwHandler::prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen) { + commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); - /** Speed (0.1 RPM) */ - commandBuffer[1] = *(commandData + 3); - commandBuffer[2] = *(commandData + 2); - commandBuffer[3] = *(commandData + 1); - commandBuffer[4] = *commandData; - /** Ramp time (ms) */ - commandBuffer[5] = *(commandData + 5); - commandBuffer[6] = *(commandData + 4); + /** Speed (0.1 RPM) */ + commandBuffer[1] = *(commandData + 3); + commandBuffer[2] = *(commandData + 2); + commandBuffer[3] = *(commandData + 1); + commandBuffer[4] = *commandData; + /** Ramp time (ms) */ + commandBuffer[5] = *(commandData + 5); + commandBuffer[6] = *(commandData + 4); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); - commandBuffer[7] = static_cast(crc & 0xFF); - commandBuffer[8] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 9; + uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); + commandBuffer[7] = static_cast(crc & 0xFF); + commandBuffer[8] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 9; } void RwHandler::handleResetStatusReply(const uint8_t* packet) { - PoolReadGuard rg(&lastResetStatusSet); - uint8_t offset = 2; - uint8_t resetStatus = *(packet + offset); - if (resetStatus != RwDefinitions::CLEARED) { - internalState = InternalState::CLEAR_RESET_STATUS; - lastResetStatusSet.lastResetStatus = resetStatus; - } - lastResetStatusSet.currentResetStatus = resetStatus; + PoolReadGuard rg(&lastResetStatusSet); + uint8_t offset = 2; + uint8_t resetStatus = *(packet + offset); + if (resetStatus != RwDefinitions::CLEARED) { + internalState = InternalState::CLEAR_RESET_STATUS; + lastResetStatusSet.lastResetStatus = resetStatus; + } + lastResetStatusSet.currentResetStatus = resetStatus; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleResetStatusReply: Last reset status: " + sif::info << "RwHandler::handleResetStatusReply: Last reset status: " << static_cast(lastResetStatusSet.lastResetStatus.value) << std::endl; - sif::info << "RwHandler::handleResetStatusReply: Current reset status: " + sif::info << "RwHandler::handleResetStatusReply: Current reset status: " << static_cast(lastResetStatusSet.currentResetStatus.value) << std::endl; #endif } void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { - PoolReadGuard rg(&statusSet); - uint8_t offset = 2; - statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - statusSet.state = *(packet + offset); - offset += 1; - statusSet.clcMode = *(packet + offset); + PoolReadGuard rg(&statusSet); + uint8_t offset = 2; + statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + statusSet.state = *(packet + offset); + offset += 1; + statusSet.clcMode = *(packet + offset); - if (statusSet.state == RwDefinitions::STATE_ERROR) { - /** - * This requires the commanding of the init reaction wheel controller command to recover - * form error state which must be handled by the FDIR instance. - */ - triggerEvent(ERROR_STATE); - sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" - << std::endl; - } + if (statusSet.state == RwDefinitions::STATE_ERROR) { + /** + * This requires the commanding of the init reaction wheel controller command to recover + * form error state which must be handled by the FDIR instance. + */ + triggerEvent(ERROR_STATE); + sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" << std::endl; + } #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed + sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " - << statusSet.referenceSpeed << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: State is: " - << (unsigned int) statusSet.state.value << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " - << (unsigned int) statusSet.clcMode.value << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " << statusSet.referenceSpeed + << " * 0.1 RPM" << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: State is: " + << (unsigned int)statusSet.state.value << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " + << (unsigned int)statusSet.clcMode.value << std::endl; #endif } void RwHandler::handleTemperatureReply(const uint8_t* packet) { - PoolReadGuard rg(&temperatureSet); - uint8_t offset = 2; - temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); + PoolReadGuard rg(&temperatureSet); + uint8_t offset = 2; + temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleTemperatureReply: Temperature: " + sif::info << "RwHandler::handleTemperatureReply: Temperature: " << temperatureSet.temperatureCelcius << " °C" << std::endl; #endif } void RwHandler::handleGetTelemetryReply(const uint8_t* packet) { - PoolReadGuard rg(&tmDataset); - uint8_t offset = 2; - tmDataset.lastResetStatus = *(packet + offset); - offset += 1; - tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.rwState = *(packet + offset); - offset += 1; - tmDataset.rwClcMode = *(packet + offset); - offset += 1; - tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); - offset += 4; - tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 8 | *(packet + offset); + PoolReadGuard rg(&tmDataset); + uint8_t offset = 2; + tmDataset.lastResetStatus = *(packet + offset); + offset += 1; + tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.pressureSensorTemperature = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | *(packet + offset + 1) << 8 | + *(packet + offset); + offset += 4; + tmDataset.pressure = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.rwState = *(packet + offset); + offset += 1; + tmDataset.rwClcMode = *(packet + offset); + offset += 1; + tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | + *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | + *(packet + offset + 1) << 8 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 - sif::info << "RwHandler::handleTemperatureReply: Last reset status: " + sif::info << "RwHandler::handleTemperatureReply: Last reset status: " << static_cast(tmDataset.lastResetStatus.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature + sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: " + sif::info << "RwHandler::handleTemperatureReply: Pressure sensor temperature: " << tmDataset.pressureSensorTemperature << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Pressure " - << tmDataset.pressure << std::endl; - sif::info << "RwHandler::handleTemperatureReply: State: " + sif::info << "RwHandler::handleTemperatureReply: Pressure " << tmDataset.pressure << std::endl; + sif::info << "RwHandler::handleTemperatureReply: State: " << static_cast(tmDataset.rwState.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: CLC mode: " + sif::info << "RwHandler::handleTemperatureReply: CLC mode: " << static_cast(tmDataset.rwClcMode.value) << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed + sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed + sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: " << tmDataset.numOfInvalidCrcPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: " << tmDataset.numOfInvalidLenPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: " + sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: " << tmDataset.numOfInvalidCmdPackets << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: " + sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: " << tmDataset.numOfCmdExecutedReplies << std::endl; - sif::info << "RwHandler::handleTemperatureReply: Number of command replies: " + sif::info << "RwHandler::handleTemperatureReply: Number of command replies: " << tmDataset.numOfCmdReplies << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: " + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: " << tmDataset.uartNumOfBytesWritten << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: " + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: " << tmDataset.uartNumOfBytesRead << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: " << tmDataset.uartNumOfParityErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: " << tmDataset.uartNumOfNoiseErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: " << tmDataset.uartNumOfFrameErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: " << tmDataset.uartNumOfRegisterOverrunErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: " + sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: " << tmDataset.uartTotalNumOfErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: " << tmDataset.spiNumOfBytesWritten << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: " << tmDataset.spiNumOfBytesRead << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: " << tmDataset.spiNumOfRegisterOverrunErrors << std::endl; - sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: " + sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: " << tmDataset.spiTotalNumOfErrors << std::endl; #endif } diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 57895ca6..31b88e01 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -2,8 +2,8 @@ #define MISSION_DEVICES_RWHANDLER_H_ #include -#include #include +#include #include /** @@ -16,141 +16,135 @@ * * @author J. Meier */ -class RwHandler: public DeviceHandlerBase { -public: +class RwHandler : public DeviceHandlerBase { + public: + /** + * @brief Constructor + * + * @param objectId + * @param comIF + * @param comCookie + * @param gpioComIF Pointer to gpio communication interface + * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled + * to high to enable the device. + */ + RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, LinuxLibgpioIF* gpioComIF, + gpioId_t enableGpio); + virtual ~RwHandler(); - /** - * @brief Constructor - * - * @param objectId - * @param comIF - * @param comCookie - * @param gpioComIF Pointer to gpio communication interface - * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled - * to high to enable the device. - */ - RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, - LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio); - virtual ~RwHandler(); + static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; - static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; + static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call + static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing + //! start sign 0x7E + static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid + //! substitution combination + static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E + static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. + static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); + //! [EXPORT] : [COMMENT] Expected a start marker as first byte + static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); - static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call - static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing start sign 0x7E - static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid substitution combination - static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); - //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E - static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. - static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); - //! [EXPORT] : [COMMENT] Expected a start marker as first byte - static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); + protected: + void doStartUp() override; + void doShutDown() override; + 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; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; -protected: - void doStartUp() override; - void doShutDown() override; - 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; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + private: + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; -private: + //! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in + //! the range of [-65000; 1000] or [1000; 65000] + static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received. + static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6. + static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Command execution failed + static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc + static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; + //! [EXPORT] : [COMMENT] Reaction wheel signals an error state + static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); - //! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in the range of [-65000; 1000] or [1000; 65000] - static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received. - static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1); - //! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6. - static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2); - //! [EXPORT] : [COMMENT] Command execution failed - static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3); - //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc - static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); + LinuxLibgpioIF* gpioComIF = nullptr; + gpioId_t enableGpio = gpio::NO_GPIO; - //! [EXPORT] : [COMMENT] Reaction wheel signals an error state - static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); + RwDefinitions::TemperatureSet temperatureSet; + RwDefinitions::StatusSet statusSet; + RwDefinitions::LastResetSatus lastResetStatusSet; + RwDefinitions::TmDataset tmDataset; - LinuxLibgpioIF* gpioComIF = nullptr; - gpioId_t enableGpio = gpio::NO_GPIO; + uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; - RwDefinitions::TemperatureSet temperatureSet; - RwDefinitions::StatusSet statusSet; - RwDefinitions::LastResetSatus lastResetStatusSet; - RwDefinitions::TmDataset tmDataset; + enum class InternalState { GET_RESET_STATUS, CLEAR_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS }; + InternalState internalState = InternalState::GET_RESET_STATUS; - uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; + size_t sizeOfReply = 0; - enum class InternalState { - GET_RESET_STATUS, - CLEAR_RESET_STATUS, - READ_TEMPERATURE, - GET_RW_SATUS - }; + /** + * @brief This function can be used to build commands which do not contain any data apart + * from the command id and the CRC. + * @param commandId The command id of the command to build. + */ + void prepareSimpleCommand(DeviceCommandId_t id); - InternalState internalState = InternalState::GET_RESET_STATUS; + /** + * @brief This function checks if the receiced speed and ramp time to set are in a valid + * range. + * @return RETURN_OK if successful, otherwise error code. + */ + ReturnValue_t checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen); - size_t sizeOfReply = 0; + /** + * @brief This function prepares the set speed command from the commandData received with + * an action message. + */ + void prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen); - /** - * @brief This function can be used to build commands which do not contain any data apart - * from the command id and the CRC. - * @param commandId The command id of the command to build. - */ - void prepareSimpleCommand(DeviceCommandId_t id); + /** + * @brief This function writes the last reset status retrieved with the get last reset status + * command into the reset status dataset. + * + * @param packet Pointer to the buffer holding the reply data. + */ + void handleResetStatusReply(const uint8_t* packet); - /** - * @brief This function checks if the receiced speed and ramp time to set are in a valid - * range. - * @return RETURN_OK if successful, otherwise error code. - */ - ReturnValue_t checkSpeedAndRampTime(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function handles the reply of the get temperature command. + * + * @param packet Pointer to the reply data + */ + void handleTemperatureReply(const uint8_t* packet); - /** - * @brief This function prepares the set speed command from the commandData received with - * an action message. - */ - void prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function fills the status set with the data from the get-status-reply. + */ + void handleGetRwStatusReply(const uint8_t* packet); - /** - * @brief This function writes the last reset status retrieved with the get last reset status - * command into the reset status dataset. - * - * @param packet Pointer to the buffer holding the reply data. - */ - void handleResetStatusReply(const uint8_t* packet); - - /** - * @brief This function handles the reply of the get temperature command. - * - * @param packet Pointer to the reply data - */ - void handleTemperatureReply(const uint8_t* packet); - - /** - * @brief This function fills the status set with the data from the get-status-reply. - */ - void handleGetRwStatusReply(const uint8_t* packet); - - /** - * @brief This function fills the tmDataset with the reply data requested with get telemetry - * command. - */ - void handleGetTelemetryReply(const uint8_t* packet); + /** + * @brief This function fills the tmDataset with the reply data requested with get telemetry + * command. + */ + void handleGetTelemetryReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_RWHANDLER_H_ */ diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 9f359bd1..8694f261 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -1,464 +1,451 @@ +#include +#include +#include + #include "OBSWConfig.h" -#include -#include -#include - - -SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) { - if (comCookie == NULL) { - sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; - } +SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) { + if (comCookie == NULL) { + sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; + } } -SyrlinksHkHandler::~SyrlinksHkHandler() { +SyrlinksHkHandler::~SyrlinksHkHandler() {} + +void SyrlinksHkHandler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } } +void SyrlinksHkHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } -void SyrlinksHkHandler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } -} - -void SyrlinksHkHandler::doShutDown(){ - setMode(_MODE_POWER_DOWN); -} - -ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - switch (nextCommand) { - case(SYRLINKS::READ_RX_STATUS_REGISTERS): - *id = SYRLINKS::READ_RX_STATUS_REGISTERS; - nextCommand = SYRLINKS::READ_TX_STATUS; - break; - case(SYRLINKS::READ_TX_STATUS): - *id = SYRLINKS::READ_TX_STATUS; - nextCommand = SYRLINKS::READ_TX_WAVEFORM; - break; - case(SYRLINKS::READ_TX_WAVEFORM): - *id = SYRLINKS::READ_TX_WAVEFORM; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - break; - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - break; - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; - break; +ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + switch (nextCommand) { + case (SYRLINKS::READ_RX_STATUS_REGISTERS): + *id = SYRLINKS::READ_RX_STATUS_REGISTERS; + nextCommand = SYRLINKS::READ_TX_STATUS; + break; + case (SYRLINKS::READ_TX_STATUS): + *id = SYRLINKS::READ_TX_STATUS; + nextCommand = SYRLINKS::READ_TX_WAVEFORM; + break; + case (SYRLINKS::READ_TX_WAVEFORM): + *id = SYRLINKS::READ_TX_WAVEFORM; + nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + break; + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): + *id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + break; + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): + *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + break; default: - sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid" - << "command id" << std::endl; - break; + sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid" + << "command id" << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); +} + +ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (SYRLINKS::RESET_UNIT): { + resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); + rawPacketLen = resetCommand.size(); + rawPacket = commandBuffer; + return RETURN_OK; } - return buildCommandFromCommand(*id, NULL, 0); -} - -ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(SYRLINKS::RESET_UNIT): { - resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); - rawPacketLen = resetCommand.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_STANDBY): { - setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); - rawPacketLen = setTxModeStandby.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_MODULATION): { - setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), 0); - rawPacketLen = setTxModeModulation.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::SET_TX_MODE_CW): { - setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); - rawPacketLen = setTxModeCw.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_RX_STATUS_REGISTERS): { - readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), readRxStatusRegCommand.size(), 0); - rawPacketLen = readRxStatusRegCommand.size(); - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_STATUS): { - readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxStatus.size(); - rememberCommandId = SYRLINKS::READ_TX_STATUS; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_WAVEFORM): { - readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxWaveform.size(); - rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { - readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxAgcValueHighByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - rawPacket = commandBuffer; - return RETURN_OK; - } - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { - readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxAgcValueLowByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - rawPacket = commandBuffer; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; + case (SYRLINKS::SET_TX_MODE_STANDBY): { + setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); + rawPacketLen = setTxModeStandby.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::SET_TX_MODE_MODULATION): { + setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), + 0); + rawPacketLen = setTxModeModulation.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::SET_TX_MODE_CW): { + setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); + rawPacketLen = setTxModeCw.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_RX_STATUS_REGISTERS): { + readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), + readRxStatusRegCommand.size(), 0); + rawPacketLen = readRxStatusRegCommand.size(); + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_STATUS): { + readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxStatus.size(); + rememberCommandId = SYRLINKS::READ_TX_STATUS; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_WAVEFORM): { + readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxWaveform.size(); + rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { + readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxAgcValueHighByte.size(); + rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + } + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { + readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); + rawPacketLen = readTxAgcValueLowByte.size(); + rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + rawPacket = commandBuffer; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } void SyrlinksHkHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false, - true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE, - false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, - SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, - false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, - SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false, + true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE, + false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, SYRLINKS::ACK_SIZE, + false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, false, + true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, + SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); } -ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { +ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + ReturnValue_t result = RETURN_OK; - ReturnValue_t result = RETURN_OK; + if (*start != '<') { + sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; + return MISSING_START_FRAME_CHARACTER; + } - if(*start != '<') { - sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; - return MISSING_START_FRAME_CHARACTER; - } + switch (*(start + 1)) { + case ('A'): + *foundLen = SYRLINKS::ACK_SIZE; + *foundId = SYRLINKS::ACK_REPLY; + break; + case ('E'): + *foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE; + *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; + break; + case ('R'): + *foundId = rememberCommandId; + *foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE; + break; + default: + sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; + result = IGNORE_REPLY_DATA; + break; + } - switch(*(start + 1)) { - case('A'): - *foundLen = SYRLINKS::ACK_SIZE; - *foundId = SYRLINKS::ACK_REPLY; - break; - case('E'): - *foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE; - *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; - break; - case('R'): - *foundId = rememberCommandId; - *foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE; - break; - default: - sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; - result = IGNORE_REPLY_DATA; - break; - } - - return result; + return result; } -ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { +ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + ReturnValue_t result; - ReturnValue_t result; - - switch (id) { + switch (id) { case (SYRLINKS::ACK_REPLY): - result = verifyReply(packet, SYRLINKS::ACK_SIZE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has " - "invalid crc" << std::endl; - return CRC_FAILURE; - } - result = parseReplyStatus(reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); - if (result != RETURN_OK) { - return result; - } - break; - case(SYRLINKS::READ_RX_STATUS_REGISTERS): - result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseRxStatusRegistersReply(packet); - break; - case(SYRLINKS::READ_TX_STATUS): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseTxStatusReply(packet); - break; - case(SYRLINKS::READ_TX_WAVEFORM): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseTxWaveformReply(packet); - break; - case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseAgcHighByte(packet); - break; - case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " - << "has invalid crc" << std::endl; - return CRC_FAILURE; - } - parseAgcLowByte(packet); - break; - default: { - sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" - << std::endl; - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - } + result = verifyReply(packet, SYRLINKS::ACK_SIZE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has " + "invalid crc" + << std::endl; + return CRC_FAILURE; + } + result = + parseReplyStatus(reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); + if (result != RETURN_OK) { + return result; + } + break; + case (SYRLINKS::READ_RX_STATUS_REGISTERS): + result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseRxStatusRegistersReply(packet); + break; + case (SYRLINKS::READ_TX_STATUS): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseTxStatusReply(packet); + break; + case (SYRLINKS::READ_TX_WAVEFORM): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseTxWaveformReply(packet); + break; + case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseAgcHighByte(packet); + break; + case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseAgcLowByte(packet); + break; + default: { + sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } - return RETURN_OK; + return RETURN_OK; } LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) { - if (sid == rxDataset.getSid()) { - return &rxDataset; - } - else if (sid== txDataset.getSid()) { - return &txDataset; - } - else { - sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; - return nullptr; - } + if (sid == rxDataset.getSid()) { + return &rxDataset; + } else if (sid == txDataset.getSid()) { + return &txDataset; + } else { + sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; + return nullptr; + } } std::string SyrlinksHkHandler::convertUint16ToHexString(uint16_t intValue) { - std::stringstream stream; - stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; - return stream.str(); + std::stringstream stream; + stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; + return stream.str(); } uint8_t SyrlinksHkHandler::convertHexStringToUint8(const char* twoChars) { - uint32_t value; - std::string hexString(twoChars, 2); - std::stringstream stream; - stream << std::hex << hexString; - stream >> value; - return static_cast(value); + uint32_t value; + std::string hexString(twoChars, 2); + std::stringstream stream; + stream << std::hex << hexString; + stream >> value; + return static_cast(value); } uint16_t SyrlinksHkHandler::convertHexStringToUint16(const char* fourChars) { - uint16_t value = 0; - value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars+2); - return value; + uint16_t value = 0; + value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars + 2); + return value; } -uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters, uint8_t numberOfChars) { +uint32_t SyrlinksHkHandler::convertHexStringToUint32(const char* characters, + uint8_t numberOfChars) { + uint32_t value = 0; - uint32_t value = 0; - - switch (numberOfChars) { + switch (numberOfChars) { case 6: - value = convertHexStringToUint8(characters) << 16 - | convertHexStringToUint8(characters + 2) << 8 - | convertHexStringToUint8(characters + 4); - return value; + value = convertHexStringToUint8(characters) << 16 | + convertHexStringToUint8(characters + 2) << 8 | + convertHexStringToUint8(characters + 4); + return value; case 8: - value = convertHexStringToUint8(characters) << 24 - | convertHexStringToUint8(characters + 2) << 16 - | convertHexStringToUint8(characters + 4) << 8 - | convertHexStringToUint8(characters + 4); - return value; + value = convertHexStringToUint8(characters) << 24 | + convertHexStringToUint8(characters + 2) << 16 | + convertHexStringToUint8(characters + 4) << 8 | + convertHexStringToUint8(characters + 4); + return value; default: - sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. " - << "Must be either 6 or 8" << std::endl; - return 0; - } + sif::debug << "SyrlinksHkHandler::convertHexStringToUint32: Invalid number of characters. " + << "Must be either 6 or 8" << std::endl; + return 0; + } } ReturnValue_t SyrlinksHkHandler::parseReplyStatus(const char* status) { - switch (*status) { + switch (*status) { case '0': - return RETURN_OK; + return RETURN_OK; case '1': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" - << std::endl; - return UART_FRAMIN_OR_PARITY_ERROR_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" << std::endl; + return UART_FRAMIN_OR_PARITY_ERROR_ACK; case '2': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; - return BAD_CHARACTER_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; + return BAD_CHARACTER_ACK; case '3': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value " - << "detected" << std::endl; - return BAD_PARAMETER_VALUE_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad parameter value (unexpected value " + << "detected" << std::endl; + return BAD_PARAMETER_VALUE_ACK; case '4': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl; - return BAD_END_OF_FRAME_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad end of frame" << std::endl; + return BAD_END_OF_FRAME_ACK; case '5': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access" - << " a protected register" << std::endl; - return UNKNOWN_COMMAND_ID_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Unknown command id or attempt to access" + << " a protected register" << std::endl; + return UNKNOWN_COMMAND_ID_ACK; case '6': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl; - return BAD_CRC_ACK; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad CRC" << std::endl; + return BAD_CRC_ACK; default: - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid " - << "status id" << std::endl; - return RETURN_FAILED; - } + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Status reply contains an invalid " + << "status id" << std::endl; + return RETURN_FAILED; + } } ReturnValue_t SyrlinksHkHandler::verifyReply(const uint8_t* packet, uint8_t size) { - int result = 0; - /* Calculate crc from received packet */ - uint16_t crc = CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, - CRC_INITIAL_VALUE); - std::string recalculatedCrc = convertUint16ToHexString(crc); + int result = 0; + /* Calculate crc from received packet */ + uint16_t crc = + CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, CRC_INITIAL_VALUE); + std::string recalculatedCrc = convertUint16ToHexString(crc); - const char* startOfCrc = reinterpret_cast(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION); - const char* endOfCrc = reinterpret_cast(packet + size - 1); + const char* startOfCrc = + reinterpret_cast(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION); + const char* endOfCrc = reinterpret_cast(packet + size - 1); - std::string replyCrc(startOfCrc, endOfCrc); + std::string replyCrc(startOfCrc, endOfCrc); - result = recalculatedCrc.compare(replyCrc); - if (result != 0) { - return RETURN_FAILED; - } - return RETURN_OK; + result = recalculatedCrc.compare(replyCrc); + if (result != 0) { + return RETURN_FAILED; + } + return RETURN_OK; } void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { - PoolReadGuard readHelper(&rxDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); - offset += 2; - rxDataset.rxSensitivity = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxFrequencyShift = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast(packet + offset)); - offset += 4; - rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast(packet + offset)); - offset += 4; - offset += 2; // reserved register - rxDataset.rxDemodEb= convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxDemodN0= convertHexStringToUint32(reinterpret_cast(packet + offset), 6); - offset += 6; - rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&rxDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); + offset += 2; + rxDataset.rxSensitivity = + convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxFrequencyShift = + convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxIqPower = convertHexStringToUint16(reinterpret_cast(packet + offset)); + offset += 4; + rxDataset.rxAgcValue = convertHexStringToUint16(reinterpret_cast(packet + offset)); + offset += 4; + offset += 2; // reserved register + rxDataset.rxDemodEb = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxDemodN0 = convertHexStringToUint32(reinterpret_cast(packet + offset), 6); + offset += 6; + rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value << std::endl; - sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; - sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; - sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; - sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; - sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; - sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; - sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; + sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value + << std::endl; + sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; + sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; + sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; + sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; + sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; + sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; + sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; #endif } void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int) txDataset.txStatus.value + sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value << std::endl; #endif } void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int) txDataset.txWaveform.value + sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value << std::endl; #endif } void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + txDataset.txAgcValue = agcValueHighByte << 8 | + convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; + sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; #endif } void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) { - PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; - agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); + PoolReadGuard readHelper(&txDataset); + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); } -void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid(){ +void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid() {} -} - -uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; -} +uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { + LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry({0})); + localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry( { 0 })); - localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry( { 0 })); - - return HasReturnvaluesIF::RETURN_OK; -} - -void SyrlinksHkHandler::setModeNormal() { - mode = MODE_NORMAL; + return HasReturnvaluesIF::RETURN_OK; } +void SyrlinksHkHandler::setModeNormal() { mode = MODE_NORMAL; } diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index bf8a489a..b2e893b2 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -13,166 +13,162 @@ * * @author J. Meier */ -class SyrlinksHkHandler: public DeviceHandlerBase { -public: +class SyrlinksHkHandler : public DeviceHandlerBase { + public: + SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + virtual ~SyrlinksHkHandler(); - SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~SyrlinksHkHandler(); + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); + protected: + void doStartUp() override; + void doShutDown() override; + 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; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; -protected: - void doStartUp() override; - void doShutDown() override; - 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; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + private: + static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; -private: + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); + static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1); + static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2); + static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6); + static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7); + static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8); - static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; + static const uint8_t CRC_INITIAL_VALUE = 0x0; - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); - static const ReturnValue_t UART_FRAMIN_OR_PARITY_ERROR_ACK = MAKE_RETURN_CODE(0xA1); - static const ReturnValue_t BAD_CHARACTER_ACK = MAKE_RETURN_CODE(0xA2); - static const ReturnValue_t BAD_PARAMETER_VALUE_ACK = MAKE_RETURN_CODE(0xA3); - static const ReturnValue_t BAD_END_OF_FRAME_ACK = MAKE_RETURN_CODE(0xA4); - static const ReturnValue_t UNKNOWN_COMMAND_ID_ACK = MAKE_RETURN_CODE(0xA5); - static const ReturnValue_t BAD_CRC_ACK = MAKE_RETURN_CODE(0xA6); - static const ReturnValue_t REPLY_WRONG_SIZE = MAKE_RETURN_CODE(0xA7); - static const ReturnValue_t MISSING_START_FRAME_CHARACTER = MAKE_RETURN_CODE(0xA8); + std::string resetCommand = ""; + std::string readRxStatusRegCommand = ""; + std::string setTxModeStandby = ""; + /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ + std::string setTxModeModulation = ""; + std::string setTxModeCw = ""; + std::string readTxStatus = ""; + std::string readTxWaveform = ""; + std::string readTxAgcValueHighByte = ""; + std::string readTxAgcValueLowByte = ""; - static const uint8_t CRC_INITIAL_VALUE = 0x0; + /** + * In some cases it is not possible to extract from the received reply the information about + * the associated command. This variable is thus used to remember the command id. + */ + DeviceCommandId_t rememberCommandId = SYRLINKS::NONE; - std::string resetCommand = ""; - std::string readRxStatusRegCommand = ""; - std::string setTxModeStandby = ""; - /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ - std::string setTxModeModulation = ""; - std::string setTxModeCw = ""; - std::string readTxStatus = ""; - std::string readTxWaveform = ""; - std::string readTxAgcValueHighByte = ""; - std::string readTxAgcValueLowByte = ""; + SYRLINKS::RxDataset rxDataset; + SYRLINKS::TxDataset txDataset; - /** - * In some cases it is not possible to extract from the received reply the information about - * the associated command. This variable is thus used to remember the command id. - */ - DeviceCommandId_t rememberCommandId = SYRLINKS::NONE; + uint8_t agcValueHighByte; - SYRLINKS::RxDataset rxDataset; - SYRLINKS::TxDataset txDataset; + uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; - uint8_t agcValueHighByte; + /** + * This object is used to store the id of the next command to execute. This controls the + * read out of multiple registers which can not be fetched with one single command. + */ + DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; - uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; + /** + * @brief This function converts an uint16_t into its hexadecimal string representation. + * + * @param intValue The value to convert. + * + * @return An std::string object containing the hex representation of intValue. + */ + std::string convertUint16ToHexString(uint16_t intValue); - /** - * This object is used to store the id of the next command to execute. This controls the - * read out of multiple registers which can not be fetched with one single command. - */ - DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + /** + * @brief This function converts a hex number represented by to chars to an 8-bit integer. + * + * @param twoChars Pointer to the two characters representing the hex value. + * + * @details E.g. when twoChars points to an array with the two characters "A5" then the function + * will return 0xA5. + * @return The converted integer. + */ + uint8_t convertHexStringToUint8(const char* twoChars); - /** - * @brief This function converts an uint16_t into its hexadecimal string representation. - * - * @param intValue The value to convert. - * - * @return An std::string object containing the hex representation of intValue. - */ - std::string convertUint16ToHexString(uint16_t intValue); + /** + * @brief This function converts a hex number represented by 4 chars to an uint16_t. + * + * @param Pointer to the fourCharacters representing the 16-bit integer. + * + * @return The uint16_t result. + */ + uint16_t convertHexStringToUint16(const char* fourChars); - /** - * @brief This function converts a hex number represented by to chars to an 8-bit integer. - * - * @param twoChars Pointer to the two characters representing the hex value. - * - * @details E.g. when twoChars points to an array with the two characters "A5" then the function - * will return 0xA5. - * @return The converted integer. - */ - uint8_t convertHexStringToUint8(const char* twoChars); + /** + * @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t. + * + * @param characters Pointer to the hex characters array. + * @param numberOfChars Number of characters representing the hex value. Must be 6 or 8. + * + * @return The uint32_t value. + */ + uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars); - /** - * @brief This function converts a hex number represented by 4 chars to an uint16_t. - * - * @param Pointer to the fourCharacters representing the 16-bit integer. - * - * @return The uint16_t result. - */ - uint16_t convertHexStringToUint16(const char* fourChars); + /** + * @brief This function parses the status reply + * @param status Pointer to the status information. + * + * @details Some commands reply with a status message giving information about the preceding + * command transmission and/or execution was successful. + */ + ReturnValue_t parseReplyStatus(const char* status); - /** - * @brief Function converts a hex number represented by 6 or 8 characters to an uint32_t. - * - * @param characters Pointer to the hex characters array. - * @param numberOfChars Number of characters representing the hex value. Must be 6 or 8. - * - * @return The uint32_t value. - */ - uint32_t convertHexStringToUint32(const char* characters, uint8_t numberOfChars); + /** + * @brief Function verifies the received reply from the syrlinks by recalculating and + * comparing the crc. + * + * @param packet Pointer to the received reply. + * @param size Size of the whole packet including the crc and the packet termination + * character '>'. + * + * @return RETURN_OK if successful, otherwise RETURN_FAILED. + */ + ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size); - /** - * @brief This function parses the status reply - * @param status Pointer to the status information. - * - * @details Some commands reply with a status message giving information about the preceding - * command transmission and/or execution was successful. - */ - ReturnValue_t parseReplyStatus(const char* status); + /** + * @brief This function extracts the data from a rx status registers reply and writes the + * information to the status registers dataset. + * @param packet Pointer to the reply packet. + */ + void parseRxStatusRegistersReply(const uint8_t* packet); - /** - * @brief Function verifies the received reply from the syrlinks by recalculating and - * comparing the crc. - * - * @param packet Pointer to the received reply. - * @param size Size of the whole packet including the crc and the packet termination - * character '>'. - * - * @return RETURN_OK if successful, otherwise RETURN_FAILED. - */ - ReturnValue_t verifyReply(const uint8_t* packet, uint8_t size); + /** + * @brief This function writes the read tx status register to the txStatusDataset. + * @param packet Pointer to the received packet. + */ + void parseTxStatusReply(const uint8_t* packet); - /** - * @brief This function extracts the data from a rx status registers reply and writes the - * information to the status registers dataset. - * @param packet Pointer to the reply packet. - */ - void parseRxStatusRegistersReply(const uint8_t* packet); + /** + * @brief This function writes the received waveform configuration to the txDataset. + */ + void parseTxWaveformReply(const uint8_t* packet); - /** - * @brief This function writes the read tx status register to the txStatusDataset. - * @param packet Pointer to the received packet. - */ - void parseTxStatusReply(const uint8_t* packet); - - /** - * @brief This function writes the received waveform configuration to the txDataset. - */ - void parseTxWaveformReply(const uint8_t* packet); - - /** - * @brief The agc value is split over two registers. The parse agc functions are used to get - * the values from the received reply and write them into the txDataset. - */ - void parseAgcLowByte(const uint8_t* packet); - void parseAgcHighByte(const uint8_t* packet); + /** + * @brief The agc value is split over two registers. The parse agc functions are used to get + * the values from the received reply and write them into the txDataset. + */ + void parseAgcLowByte(const uint8_t* packet); + void parseAgcHighByte(const uint8_t* packet); }; #endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */ diff --git a/mission/devices/Tmp1075Handler.cpp b/mission/devices/Tmp1075Handler.cpp index 95b8685f..59298851 100644 --- a/mission/devices/Tmp1075Handler.cpp +++ b/mission/devices/Tmp1075Handler.cpp @@ -1,145 +1,124 @@ +#include #include #include -#include -Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), dataset( - this) { - if (comCookie == NULL) { - sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl; - } +Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comIF, comCookie), dataset(this) { + if (comCookie == NULL) { + sif::error << "Tmp1075Handler: Invalid com cookie" << std::endl; + } } -Tmp1075Handler::~Tmp1075Handler() { +Tmp1075Handler::~Tmp1075Handler() {} + +void Tmp1075Handler::doStartUp() { + if (mode == _MODE_START_UP) { + setMode(MODE_ON); + } } +void Tmp1075Handler::doShutDown() { setMode(_MODE_POWER_DOWN); } -void Tmp1075Handler::doStartUp(){ - if(mode == _MODE_START_UP){ - setMode(MODE_ON); - } +ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + if (communicationStep == CommunicationStep::START_ADC_CONVERSION) { + *id = TMP1075::START_ADC_CONVERSION; + communicationStep = CommunicationStep::GET_TEMPERATURE; + return buildCommandFromCommand(*id, NULL, 0); + } else { + *id = TMP1075::GET_TEMP; + communicationStep = CommunicationStep::START_ADC_CONVERSION; + return buildCommandFromCommand(*id, NULL, 0); + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::doShutDown(){ - setMode(_MODE_POWER_DOWN); +ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand( - DeviceCommandId_t * id) { - - if(communicationStep == CommunicationStep::START_ADC_CONVERSION) { - *id = TMP1075::START_ADC_CONVERSION; - communicationStep = CommunicationStep::GET_TEMPERATURE; - return buildCommandFromCommand(*id, NULL, 0); - } - else { - *id = TMP1075::GET_TEMP; - communicationStep = CommunicationStep::START_ADC_CONVERSION; - return buildCommandFromCommand(*id, NULL, 0); - } - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t Tmp1075Handler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case (TMP1075::START_ADC_CONVERSION): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + prepareAdcConversionCommand(); + rawPacket = cmdBuffer; + rawPacketLen = TMP1075::CFGR_CMD_SIZE; + return RETURN_OK; + } + case (TMP1075::GET_TEMP): { + std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); + prepareGetTempCommand(); + rawPacket = cmdBuffer; + rawPacketLen = TMP1075::POINTER_REG_SIZE; + rememberCommandId = TMP1075::GET_TEMP; + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; } -ReturnValue_t Tmp1075Handler::buildTransitionDeviceCommand( - DeviceCommandId_t * id){ - return HasReturnvaluesIF::RETURN_OK; +void Tmp1075Handler::fillCommandAndReplyMap() { + this->insertInCommandMap(TMP1075::START_ADC_CONVERSION); + this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset, TMP1075::GET_TEMP_REPLY_SIZE); } -ReturnValue_t Tmp1075Handler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t * commandData, - size_t commandDataLen) { - switch(deviceCommand) { - case(TMP1075::START_ADC_CONVERSION): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - prepareAdcConversionCommand(); - rawPacket = cmdBuffer; - rawPacketLen = TMP1075::CFGR_CMD_SIZE; - return RETURN_OK; - } - case(TMP1075::GET_TEMP): { - std::memset(cmdBuffer, 0, sizeof(cmdBuffer)); - prepareGetTempCommand(); - rawPacket = cmdBuffer; - rawPacketLen = TMP1075::POINTER_REG_SIZE; - rememberCommandId = TMP1075::GET_TEMP; - return RETURN_OK; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + switch (rememberCommandId) { + case (TMP1075::GET_TEMP): + *foundId = TMP1075::GET_TEMP; + *foundLen = TMP1075::GET_TEMP_REPLY_SIZE; + rememberCommandId = TMP1075::NONE; + break; + default: + return IGNORE_REPLY_DATA; + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::fillCommandAndReplyMap(){ - this->insertInCommandMap(TMP1075::START_ADC_CONVERSION); - this->insertInCommandAndReplyMap(TMP1075::GET_TEMP, 1, &dataset, - TMP1075::GET_TEMP_REPLY_SIZE); -} - -ReturnValue_t Tmp1075Handler::scanForReply(const uint8_t *start, - size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - switch(rememberCommandId) { - case(TMP1075::GET_TEMP): - *foundId = TMP1075::GET_TEMP; - *foundLen = TMP1075::GET_TEMP_REPLY_SIZE; - rememberCommandId = TMP1075::NONE; - break; - default: - return IGNORE_REPLY_DATA; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - switch (id) { - case TMP1075::GET_TEMP: { - int16_t tempValueRaw = 0; - tempValueRaw = packet[0] << 4 | packet[1] >> 4; - float tempValue = ((static_cast(tempValueRaw)) * 0.0625); +ReturnValue_t Tmp1075Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch (id) { + case TMP1075::GET_TEMP: { + int16_t tempValueRaw = 0; + tempValueRaw = packet[0] << 4 | packet[1] >> 4; + float tempValue = ((static_cast(tempValueRaw)) * 0.0625); #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId() - << ": Temperature: " << tempValue<< " °C" - << std::endl; + sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId() + << ": Temperature: " << tempValue << " °C" << std::endl; #endif - ReturnValue_t result = dataset.read(); - if(result == HasReturnvaluesIF::RETURN_OK) { - dataset.temperatureCelcius = tempValue; - dataset.commit(); - } - break; - } + ReturnValue_t result = dataset.read(); + if (result == HasReturnvaluesIF::RETURN_OK) { + dataset.temperatureCelcius = tempValue; + dataset.commit(); + } + break; + } - default: { - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - - } - return HasReturnvaluesIF::RETURN_OK; + default: { + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + return HasReturnvaluesIF::RETURN_OK; } -void Tmp1075Handler::setNormalDatapoolEntriesInvalid(){ +void Tmp1075Handler::setNormalDatapoolEntriesInvalid() {} +void Tmp1075Handler::prepareAdcConversionCommand() { + cmdBuffer[0] = TMP1075::CFGR_ADDR; + cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8; + cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF; } -void Tmp1075Handler::prepareAdcConversionCommand(){ - cmdBuffer[0] = TMP1075::CFGR_ADDR; - cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8; - cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF; -} +void Tmp1075Handler::prepareGetTempCommand() { cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; } -void Tmp1075Handler::prepareGetTempCommand(){ - cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; -} +uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } -uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ - return 500; +ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry({0.0})); + return HasReturnvaluesIF::RETURN_OK; } - -ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry( { 0.0 })); - return HasReturnvaluesIF::RETURN_OK; -} - diff --git a/mission/devices/Tmp1075Handler.h b/mission/devices/Tmp1075Handler.h index 190ac47f..3077cf1a 100644 --- a/mission/devices/Tmp1075Handler.h +++ b/mission/devices/Tmp1075Handler.h @@ -15,54 +15,46 @@ * * @author J. Meier */ -class Tmp1075Handler: public DeviceHandlerBase { -public: +class Tmp1075Handler : public DeviceHandlerBase { + public: + Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie); + virtual ~Tmp1075Handler(); - Tmp1075Handler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie); - virtual ~Tmp1075Handler(); + protected: + void doStartUp() override; + void doShutDown() override; + 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; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; -protected: - void doStartUp() override; - void doShutDown() override; - 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; - void setNormalDatapoolEntriesInvalid() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + private: + /** + * @brief Function fills cmdBuffer with command to start the adc + * conversion for a new temperature value. + */ + void prepareAdcConversionCommand(); -private: + void prepareGetTempCommand(); - /** - * @brief Function fills cmdBuffer with command to start the adc - * conversion for a new temperature value. - */ - void prepareAdcConversionCommand(); + enum class CommunicationStep { START_ADC_CONVERSION, GET_TEMPERATURE }; - void prepareGetTempCommand(); + TMP1075::Tmp1075Dataset dataset; - enum class CommunicationStep { - START_ADC_CONVERSION, - GET_TEMPERATURE - }; + static const uint8_t MAX_CMD_LEN = 3; - TMP1075::Tmp1075Dataset dataset; - - static const uint8_t MAX_CMD_LEN = 3; - - uint8_t rememberRequestedSize = 0; - uint8_t rememberCommandId = TMP1075::NONE; - uint8_t cmdBuffer[MAX_CMD_LEN]; - CommunicationStep communicationStep = - CommunicationStep::START_ADC_CONVERSION; + uint8_t rememberRequestedSize = 0; + uint8_t rememberCommandId = TMP1075::NONE; + uint8_t cmdBuffer[MAX_CMD_LEN]; + CommunicationStep communicationStep = CommunicationStep::START_ADC_CONVERSION; }; #endif /* MISSION_DEVICES_TMP1075HANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index aea442a2..ce58f680 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -1,8 +1,8 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ -#include "fsfw/devicehandlers/DeviceHandlerIF.h" #include "fsfw/datapoollocal/StaticLocalDataSet.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" namespace GpsHyperion { @@ -11,60 +11,53 @@ static constexpr DeviceCommandId_t TRIGGER_RESET_PIN = 5; static constexpr uint32_t DATASET_ID = 0; -enum GpsPoolIds: lp_id_t { - LATITUDE = 0, - LONGITUDE = 1, - ALTITUDE = 2, - SPEED = 3, - FIX_MODE = 4, - SATS_IN_USE = 5, - SATS_IN_VIEW = 6, - UNIX_SECONDS = 7, - YEAR = 8, - MONTH = 9, - DAY = 10, - HOURS = 11, - MINUTES = 12, - SECONDS = 13 +enum GpsPoolIds : lp_id_t { + LATITUDE = 0, + LONGITUDE = 1, + ALTITUDE = 2, + SPEED = 3, + FIX_MODE = 4, + SATS_IN_USE = 5, + SATS_IN_VIEW = 6, + UNIX_SECONDS = 7, + YEAR = 8, + MONTH = 9, + DAY = 10, + HOURS = 11, + MINUTES = 12, + SECONDS = 13 }; -enum GpsFixModes: uint8_t { - INVALID = 0, - NO_FIX = 1, - FIX_2D = 2, - FIX_3D = 3 -}; +enum GpsFixModes : uint8_t { INVALID = 0, NO_FIX = 1, FIX_2D = 2, FIX_3D = 3 }; -} +} // namespace GpsHyperion -class GpsPrimaryDataset: public StaticLocalDataSet<18> { -public: - GpsPrimaryDataset(object_id_t gpsId): - StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { - setAllVariablesReadOnly(); - } +class GpsPrimaryDataset : public StaticLocalDataSet<18> { + public: + GpsPrimaryDataset(object_id_t gpsId) : StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { + setAllVariablesReadOnly(); + } - lp_var_t latitude = lp_var_t(sid.objectId, - GpsHyperion::LATITUDE, this); - lp_var_t longitude = lp_var_t(sid.objectId, - GpsHyperion::LONGITUDE, this); - lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); - lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); - lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); - lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); - lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); - lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); - lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); - lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); - lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); - lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); - lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); - lp_var_t unixSeconds = lp_var_t(sid.objectId, - GpsHyperion::UNIX_SECONDS, this); -private: - friend class GPSHyperionHandler; - GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} + lp_var_t latitude = lp_var_t(sid.objectId, GpsHyperion::LATITUDE, this); + lp_var_t longitude = lp_var_t(sid.objectId, GpsHyperion::LONGITUDE, this); + lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); + lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); + lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); + lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); + lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); + lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); + lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); + lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); + lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); + lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); + lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); + lp_var_t unixSeconds = + lp_var_t(sid.objectId, GpsHyperion::UNIX_SECONDS, this); + + private: + friend class GPSHyperionHandler; + GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GomSpacePackets.h b/mission/devices/devicedefinitions/GomSpacePackets.h index d410a3af..e6736255 100644 --- a/mission/devices/devicedefinitions/GomSpacePackets.h +++ b/mission/devices/devicedefinitions/GomSpacePackets.h @@ -2,37 +2,32 @@ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ #include -#include -#include #include +#include +#include #include - /** * @brief This class can be used to generated the command for the CspComIF * to reset the watchdog in a gomspace device. */ class WatchdogResetCommand : public SerialLinkedListAdapter { -public: + public: + WatchdogResetCommand() { setLinks(); } - WatchdogResetCommand() { - setLinks(); - } - -private: - WatchdogResetCommand(const WatchdogResetCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&magic); - } - SerializeElement cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET; - SerializeElement querySize = 1; - /* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */ - SerializeElement magic = 0x78; + private: + WatchdogResetCommand(const WatchdogResetCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&magic); + } + SerializeElement cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET; + SerializeElement querySize = 1; + /* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */ + SerializeElement magic = 0x78; }; - /** * @brief A serial linked list adapter implementation to generate ping * commands for devices supporting the CSP protocol. This command can @@ -44,33 +39,32 @@ private: * transmitted to the target device. */ class CspPingCommand : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param querySize_ The size of bytes replied by the ping request. - * Amounts to the number of bytes send. - * @param data_ Pointer to data which should be sent to the device. - * All data will be sent back by the ping target. - */ - CspPingCommand(const uint8_t* data_, uint16_t querySize_) : - querySize(querySize_), data(data_, querySize_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param querySize_ The size of bytes replied by the ping request. + * Amounts to the number of bytes send. + * @param data_ Pointer to data which should be sent to the device. + * All data will be sent back by the ping target. + */ + CspPingCommand(const uint8_t *data_, uint16_t querySize_) + : querySize(querySize_), data(data_, querySize_) { + setLinks(); + } -private: - CspPingCommand(const CspPingCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&data); - } - SerializeElement cspPort = GOMSPACE::PING_PORT; - SerializeElement querySize; - SerializeElement> data; + private: + CspPingCommand(const CspPingCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&data); + } + SerializeElement cspPort = GOMSPACE::PING_PORT; + SerializeElement querySize; + SerializeElement> data; }; - /** * @brief A serial linked list adapter implementation of the gs_rparam_query_t * struct defined in rparam.h. Can be used to build the message to set @@ -81,47 +75,49 @@ private: * and the size to query. */ class CspSetParamCommand : public SerialLinkedListAdapter { -public: + public: + CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, uint16_t checksum_, + uint16_t seq_, uint16_t total_, uint16_t addr_, const uint8_t *parameter_, + uint8_t parameterCount_) + : querySize(querySize_), + payloadlength(payloadlength_), + checksum(checksum_), + seq(seq_), + total(total_), + addr(addr_), + parameter(parameter_, parameterCount_) { + setLinks(); + } - CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, - uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_, - const uint8_t* parameter_, uint8_t parameterCount_) : - querySize(querySize_), payloadlength( - payloadlength_), checksum(checksum_), seq(seq_), total( - total_), addr(addr_), parameter(parameter_, parameterCount_) { - setLinks(); - } - -private: - CspSetParamCommand(const CspSetParamCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&payloadlength); - payloadlength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - addr.setNext(¶meter); - } - SerializeElement cspPort = GOMSPACE::PARAM_PORT; - /* Only a parameter will be set. No data will be queried with this command */ - SerializeElement querySize; - SerializeElement action = 0xFF; // param set - /* We will never set a parameter in a table other than the configuration - * table */ - SerializeElement tableId = 1; - SerializeElement payloadlength; - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; - SerializeElement> parameter; + private: + CspSetParamCommand(const CspSetParamCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&payloadlength); + payloadlength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + addr.setNext(¶meter); + } + SerializeElement cspPort = GOMSPACE::PARAM_PORT; + /* Only a parameter will be set. No data will be queried with this command */ + SerializeElement querySize; + SerializeElement action = 0xFF; // param set + /* We will never set a parameter in a table other than the configuration + * table */ + SerializeElement tableId = 1; + SerializeElement payloadlength; + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; + SerializeElement> parameter; }; - /** * @brief This class can be used to generate a get param command for the * gomspace devices which will be sent to the device communication @@ -131,50 +127,50 @@ private: * and will not be transmitted physically to the target device. */ class CspGetParamCommand : public SerialLinkedListAdapter { -public: - /* The size of the header of a gomspace CSP packet. */ - static const uint8_t GS_HDR_LENGTH = 12; + public: + /* The size of the header of a gomspace CSP packet. */ + static const uint8_t GS_HDR_LENGTH = 12; - CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, - uint16_t addresslength_, uint16_t checksum_, uint16_t seq_, - uint16_t total_, uint16_t addr_) : - querySize(querySize_), tableId(tableId_), addresslength( - addresslength_), checksum(checksum_), seq(seq_), total( - total_), addr(addr_) { - fixedValuesInit(); - setLinks(); - } + CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, uint16_t addresslength_, + uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_) + : querySize(querySize_), + tableId(tableId_), + addresslength(addresslength_), + checksum(checksum_), + seq(seq_), + total(total_), + addr(addr_) { + fixedValuesInit(); + setLinks(); + } -private: - CspGetParamCommand(const CspGetParamCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&addresslength); - addresslength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - } - void fixedValuesInit(){ - cspPort.entry = GOMSPACE::PARAM_PORT; - } - SerializeElement cspPort; - SerializeElement querySize; // size of bytes to query - /* Following information will also be physically transmitted to the target - * device*/ - SerializeElement action = 0x00; // get param - SerializeElement tableId; - SerializeElement addresslength; - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; + private: + CspGetParamCommand(const CspGetParamCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&addresslength); + addresslength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + } + void fixedValuesInit() { cspPort.entry = GOMSPACE::PARAM_PORT; } + SerializeElement cspPort; + SerializeElement querySize; // size of bytes to query + /* Following information will also be physically transmitted to the target + * device*/ + SerializeElement action = 0x00; // get param + SerializeElement tableId; + SerializeElement addresslength; + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; }; - /** * @brief This class can be used to generate a get param command for the * gomspace devices which will be sent to the device communication @@ -184,205 +180,186 @@ private: * and will not be transmitted physically to the target device. */ class RequestFullTableCommand : public SerialLinkedListAdapter { -public: + public: + RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_) + : querySize(querySize_), tableId(tableId_) { + setLinks(); + } - RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_) : - querySize(querySize_), tableId(tableId_) { - setLinks(); - } - -private: - RequestFullTableCommand(const RequestFullTableCommand &command); - void setLinks() { - setStart(&cspPort); - cspPort.setNext(&querySize); - querySize.setNext(&action); - action.setNext(&tableId); - tableId.setNext(&addresslength); - addresslength.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - } - SerializeElement cspPort = GOMSPACE::PARAM_PORT; - /** Size of bytes to query (size of csp header + size of table) */ - SerializeElement querySize; - /* Following information will also be physically transmitted to the target - * device*/ - SerializeElement action = 0x00; // get param - SerializeElement tableId; - /* Size of address. Set to 0 to get full table */ - SerializeElement addresslength = 0; - SerializeElement checksum = GOMSPACE::IGNORE_CHECKSUM; - SerializeElement seq = 0; - SerializeElement total = 0; + private: + RequestFullTableCommand(const RequestFullTableCommand &command); + void setLinks() { + setStart(&cspPort); + cspPort.setNext(&querySize); + querySize.setNext(&action); + action.setNext(&tableId); + tableId.setNext(&addresslength); + addresslength.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + } + SerializeElement cspPort = GOMSPACE::PARAM_PORT; + /** Size of bytes to query (size of csp header + size of table) */ + SerializeElement querySize; + /* Following information will also be physically transmitted to the target + * device*/ + SerializeElement action = 0x00; // get param + SerializeElement tableId; + /* Size of address. Set to 0 to get full table */ + SerializeElement addresslength = 0; + SerializeElement checksum = GOMSPACE::IGNORE_CHECKSUM; + SerializeElement seq = 0; + SerializeElement total = 0; }; - /** * @brief This class can be used to deserialize replies from gomspace devices * and extract the relevant data. */ class CspGetParamReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param payloadBuffer Pointer to a buffer to store the payload data of - * the CSP packet. - * @param payloadBufferSz The size of the payload buffer where the payload - * data will be stored. - */ - CspGetParamReply(uint8_t* payloadBuffer_, uint8_t payloadBufferSz_) : - payload(payloadBuffer_, payloadBufferSz_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param payloadBuffer Pointer to a buffer to store the payload data of + * the CSP packet. + * @param payloadBufferSz The size of the payload buffer where the payload + * data will be stored. + */ + CspGetParamReply(uint8_t *payloadBuffer_, uint8_t payloadBufferSz_) + : payload(payloadBuffer_, payloadBufferSz_) { + setLinks(); + } - uint8_t getAction(){ - return action; - } + uint8_t getAction() { return action; } - uint8_t getTableId(){ - return tableId; - } + uint8_t getTableId() { return tableId; } - uint16_t getLength(){ - return length; - } + uint16_t getLength() { return length; } - uint16_t getAddress(){ - return addr; - } + uint16_t getAddress() { return addr; } -private: - CspGetParamReply(const CspGetParamReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&length); - length.setNext(&checksum); - checksum.setNext(&seq); - seq.setNext(&total); - total.setNext(&addr); - addr.setNext(&payload); - } + private: + CspGetParamReply(const CspGetParamReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&length); + length.setNext(&checksum); + checksum.setNext(&seq); + seq.setNext(&total); + total.setNext(&addr); + addr.setNext(&payload); + } - SerializeElement action; - SerializeElement tableId; - SerializeElement length; //length of address field + payload data - SerializeElement checksum; - SerializeElement seq; - SerializeElement total; - SerializeElement addr; - SerializeElement> payload; + SerializeElement action; + SerializeElement tableId; + SerializeElement length; // length of address field + payload data + SerializeElement checksum; + SerializeElement seq; + SerializeElement total; + SerializeElement addr; + SerializeElement> payload; }; - /** * @brief This class generates telemetry packets containing data from * CSP get-parameter-replies. */ class ParamReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param payloadBuffer Pointer to a buffer to store the payload data of - * the CSP packet. - * @param payloadBufferSz The size of the payload buffer where the payload - * data will be stored. - */ - ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_, - uint16_t payloadLength_, uint8_t* payloadBuffer_) : - action(action_), tableId(tableId_), addr(addr_), payloadLength( - payloadLength_), payload(payloadBuffer_, payloadLength) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param payloadBuffer Pointer to a buffer to store the payload data of + * the CSP packet. + * @param payloadBufferSz The size of the payload buffer where the payload + * data will be stored. + */ + ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_, uint16_t payloadLength_, + uint8_t *payloadBuffer_) + : action(action_), + tableId(tableId_), + addr(addr_), + payloadLength(payloadLength_), + payload(payloadBuffer_, payloadLength) { + setLinks(); + } -private: - ParamReply(const CspGetParamReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&addr); - addr.setNext(&payloadLength); - payloadLength.setNext(&payload); - } - SerializeElement action; - SerializeElement tableId; - SerializeElement addr; - SerializeElement payloadLength; - SerializeElement> payload; + private: + ParamReply(const CspGetParamReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&addr); + addr.setNext(&payloadLength); + payloadLength.setNext(&payload); + } + SerializeElement action; + SerializeElement tableId; + SerializeElement addr; + SerializeElement payloadLength; + SerializeElement> payload; }; - /** - * @brief This class generates the reply containing data from a full housekeeping table request - * of the PDU2. + * @brief This class generates the reply containing data from a full housekeeping table + * request of the PDU2. */ class Pdu2FullTableReply : public SerialLinkedListAdapter { -public: - /** - * @brief Constructor - * - * @param action_ The command which triggered the full table request. - * @param tableId_ The id of the requested table. - * @param tableDataset_ The dataset holding the table data. - */ - Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF* tableDataset_) : - action(action_), tableId(tableId_), dataset(tableDataset_) { - setLinks(); - } + public: + /** + * @brief Constructor + * + * @param action_ The command which triggered the full table request. + * @param tableId_ The id of the requested table. + * @param tableDataset_ The dataset holding the table data. + */ + Pdu2FullTableReply(uint8_t action_, uint8_t tableId_, SerializeIF *tableDataset_) + : action(action_), tableId(tableId_), dataset(tableDataset_) { + setLinks(); + } -private: - Pdu2FullTableReply(const Pdu2FullTableReply &reply); - void setLinks() { - setStart(&action); - action.setNext(&tableId); - tableId.setNext(&dataset); - } - SerializeElement action; - SerializeElement tableId; - LinkedElement dataset; + private: + Pdu2FullTableReply(const Pdu2FullTableReply &reply); + void setLinks() { + setStart(&action); + action.setNext(&tableId); + tableId.setNext(&dataset); + } + SerializeElement action; + SerializeElement tableId; + LinkedElement dataset; }; - /** * @brief This class helps to unpack information from an action message * to set a parameter in gomspace devices. The action message can be * for example received from the PUS Service 8. */ -class SetParamMessageUnpacker: public SerialLinkedListAdapter { -public: - /* Largest parameter is a uint32_t */ - static const uint32_t MAX_SIZE = 4; +class SetParamMessageUnpacker : public SerialLinkedListAdapter { + public: + /* Largest parameter is a uint32_t */ + static const uint32_t MAX_SIZE = 4; - SetParamMessageUnpacker() { - setLinks(); - } + SetParamMessageUnpacker() { setLinks(); } - uint16_t getAddress() { - return address; - } + uint16_t getAddress() { return address; } - uint8_t* getParameter() { - return parameter->front(); - } + uint8_t *getParameter() { return parameter->front(); } - uint8_t getParameterSize(){ - return parameter->size; - } + uint8_t getParameterSize() { return parameter->size; } -private: - void setLinks() { - setStart(&address); - address.setNext(¶meter); - } - SetParamMessageUnpacker(const SetParamMessageUnpacker &message); - SerializeElement address; - SerializeElement> parameter; + private: + void setLinks() { + setStart(&address); + address.setNext(¶meter); + } + SetParamMessageUnpacker(const SetParamMessageUnpacker &message); + SerializeElement address; + SerializeElement> parameter; }; - /** * @brief This class generates a message which can be sent to the GomspaceDeviceHandler to * command a parameter change. @@ -391,76 +368,64 @@ private: * | memory address | size of parameter value | parameter value | */ class GomspaceSetParamMessage : public SerialLinkedListAdapter { -public: + public: + /* The size of the largest parameter */ + static const uint8_t MAX_SIZE = 4; - /* The size of the largest parameter */ - static const uint8_t MAX_SIZE = 4; + /** + * @brief Constructor + * + * @param memoryAddress The address of the parameter to change in the configuration table. + * @param parameterValue Pointer to the parameter value to set. + * @param parameterSize The size of the parameter. + * + */ + GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t *parameterValue, + uint8_t parameterSize) + : memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) { + setLinks(); + } - /** - * @brief Constructor - * - * @param memoryAddress The address of the parameter to change in the configuration table. - * @param parameterValue Pointer to the parameter value to set. - * @param parameterSize The size of the parameter. - * - */ - GomspaceSetParamMessage(uint16_t memoryAddress, const uint8_t* parameterValue, - uint8_t parameterSize) : - memoryAddress(memoryAddress), parameterValueBuffer(parameterValue, parameterSize, true) { - setLinks(); - } - -private: - GomspaceSetParamMessage(const GomspaceSetParamMessage &reply); - void setLinks() { - setStart(&memoryAddress); - memoryAddress.setNext(¶meterValueBuffer); - } - SerializeElement memoryAddress; - /** - * Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is - * four bytes. - */ - SerializeElement> parameterValueBuffer; + private: + GomspaceSetParamMessage(const GomspaceSetParamMessage &reply); + void setLinks() { + setStart(&memoryAddress); + memoryAddress.setNext(¶meterValueBuffer); + } + SerializeElement memoryAddress; + /** + * Parameter can be uint8_t, uint16_t or uint32_t. Thus max size of parameterValueBuffer is + * four bytes. + */ + SerializeElement> parameterValueBuffer; }; - /** * @brief This class helps to unpack information from an action message * to get a parameter from gomspace devices. The action message can be * for example received from the PUS Service 8. */ -class GetParamMessageUnpacker: public SerialLinkedListAdapter { -public: +class GetParamMessageUnpacker : public SerialLinkedListAdapter { + public: + GetParamMessageUnpacker() { setLinks(); } - GetParamMessageUnpacker() { - setLinks(); - } + uint8_t getTableId() { return tableId; } - uint8_t getTableId() { - return tableId; - } + uint16_t getAddress() { return address; } - uint16_t getAddress() { - return address; - } + uint8_t getParameterSize() { return parameterSize; } - uint8_t getParameterSize(){ - return parameterSize; - } - - -private: - GetParamMessageUnpacker(const GetParamMessageUnpacker &message); - void setLinks() { - setStart(&tableId); - tableId.setNext(&address); - address.setNext(¶meterSize); - } - SerializeElement tableId; - SerializeElement address; //The memory address offset within the table - /* The size of the requested value (e.g. temperature is a uint16_t value) */ - SerializeElement parameterSize; + private: + GetParamMessageUnpacker(const GetParamMessageUnpacker &message); + void setLinks() { + setStart(&tableId); + tableId.setNext(&address); + address.setNext(¶meterSize); + } + SerializeElement tableId; + SerializeElement address; // The memory address offset within the table + /* The size of the requested value (e.g. temperature is a uint16_t value) */ + SerializeElement parameterSize; }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ */ diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 0fbbc5b0..a575747f 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -9,12 +9,13 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ -#include -#include -#include #include +#include +#include -namespace GOMSPACE{ +#include + +namespace GOMSPACE { static const uint16_t IGNORE_CHECKSUM = 0xbb0; /** The size of the header of a gomspace CSP packet. */ static const uint8_t GS_HDR_LENGTH = 12; @@ -29,339 +30,337 @@ static const uint8_t P60_PORT_GNDWDT_RESET = 9; * Device commands are derived from the rparam.h of the gomspace lib.. * IDs above 50 are reserved for device specific commands. */ -static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t NONE = 2; // Set when no command is pending -static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND] -static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t NONE = 2; // Set when no command is pending +static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND] +static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND] //!< [EXPORT] : [COMMAND] Print switch states, voltages and currents to the console static const DeviceCommandId_t PRINT_SWITCH_V_I = 32; - -} +} // namespace GOMSPACE namespace P60System { -enum P60SytemPoolIds: lp_id_t { - P60DOCK_CURRENT_ACU_VCC, - P60DOCK_CURRENT_PDU1_VCC, - P60DOCK_CURRENT_X3_IDLE_VCC, - P60DOCK_CURRENT_PDU2_VCC, - P60DOCK_CURRENT_ACU_VBAT, - P60DOCK_CURRENT_PDU1_VBAT, - P60DOCK_CURRENT_X3_IDLE_VBAT, - P60DOCK_CURRENT_PDU2_VBAT, - P60DOCK_CURRENT_STACK_VBAT, - P60DOCK_CURRENT_STACK_3V3, - P60DOCK_CURRENT_STACK_5V, - P60DOCK_CURRENT_GS3V3, - P60DOCK_CURRENT_GS5V, - P60DOCK_VOLTAGE_ACU_VCC, - P60DOCK_VOLTAGE_PDU1_VCC, - P60DOCK_VOLTAGE_X3_IDLE_VCC, - P60DOCK_VOLTAGE_PDU2_VCC, - P60DOCK_VOLTAGE_ACU_VBAT, - P60DOCK_VOLTAGE_PDU1_VBAT, - P60DOCK_VOLTAGE_X3_IDLE_VBAT, - P60DOCK_VOLTAGE_PDU2_VBAT, - P60DOCK_VOLTAGE_STACK_VBAT, - P60DOCK_VOLTAGE_STACK_3V3, - P60DOCK_VOLTAGE_STACK_5V, - P60DOCK_VOLTAGE_GS3V3, - P60DOCK_VOLTAGE_GS5V, - P60DOCK_OUTPUTENABLE_ACU_VCC, - P60DOCK_OUTPUTENABLE_PDU1_VCC, - P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, - P60DOCK_OUTPUTENABLE_PDU2_VCC, - P60DOCK_OUTPUTENABLE_ACU_VBAT, - P60DOCK_OUTPUTENABLE_PDU1_VBAT, - P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, - P60DOCK_OUTPUTENABLE_PDU2_VBAT, - P60DOCK_OUTPUTENABLE_STACK_VBAT, - P60DOCK_OUTPUTENABLE_STACK_3V3, - P60DOCK_OUTPUTENABLE_STACK_5V, - P60DOCK_OUTPUTENABLE_GS3V3, - P60DOCK_OUTPUTENABLE_GS5V, - P60DOCK_TEMPERATURE_1, - P60DOCK_TEMPERATURE_2, - P60DOCK_BOOT_CAUSE, - P60DOCK_BOOT_CNT, - P60DOCK_UPTIME, - P60DOCK_RESETCAUSE, - P60DOCK_BATT_MODE, - P60DOCK_HEATER_ON, - P60DOCK_CONV_5V_ENABLE_STATUS, - P60DOCK_LATCHUP_ACU_VCC, - P60DOCK_LATCHUP_PDU1_VCC, - P60DOCK_LATCHUP_X3_IDLE_VCC, - P60DOCK_LATCHUP_PDU2_VCC, - P60DOCK_LATCHUP_ACU_VBAT, - P60DOCK_LATCHUP_PDU1_VBAT, - P60DOCK_LATCHUP_X3_IDLE_VBAT, - P60DOCK_LATCHUP_PDU2_VBAT, - P60DOCK_LATCHUP_STACK_VBAT, - P60DOCK_LATCHUP_STACK_3V3, - P60DOCK_LATCHUP_STACK_5V, - P60DOCK_LATCHUP_GS3V3, - P60DOCK_LATCHUP_GS5V, - P60DOCK_VBAT_VALUE, - P60DOCK_VCC_CURRENT_VALUE, - P60DOCK_BATTERY_CURRENT, - P60DOCK_BATTERY_VOLTAGE, - P60DOCK_BATTERY_TEMPERATURE_1, - P60DOCK_BATTERY_TEMPERATURE_2, - P60DOCK_DEVICE_0, - P60DOCK_DEVICE_1, - P60DOCK_DEVICE_2, - P60DOCK_DEVICE_3, - P60DOCK_DEVICE_4, - P60DOCK_DEVICE_5, - P60DOCK_DEVICE_6, - P60DOCK_DEVICE_7, - P60DOCK_DEVICE_0_STATUS, - P60DOCK_DEVICE_1_STATUS, - P60DOCK_DEVICE_2_STATUS, - P60DOCK_DEVICE_3_STATUS, - P60DOCK_DEVICE_4_STATUS, - P60DOCK_DEVICE_5_STATUS, - P60DOCK_DEVICE_6_STATUS, - P60DOCK_DEVICE_7_STATUS, - P60DOCK_DEVICE_TYPE_GROUP, - P60DOCK_DEVICE_STATUS_GROUP, - P60DOCK_DEARM_STATUS, - P60DOCK_WDT_CNT_GND, - P60DOCK_WDT_CNT_I2C, - P60DOCK_WDT_CNT_CAN, - P60DOCK_WDT_CNT_CSP_1, - P60DOCK_WDT_CNT_CSP_2, - P60DOCK_WDT_GND_LEFT, - P60DOCK_WDT_I2C_LEFT, - P60DOCK_WDT_CAN_LEFT, - P60DOCK_WDT_CSP_LEFT_1, - P60DOCK_WDT_CSP_LEFT_2, - P60DOCK_BATT_CHARGE_CURRENT, - P60DOCK_BATT_DISCHARGE_CURRENT, - P60DOCK_ANT6_DEPL, - P60DOCK_AR6_DEPL, +enum P60SytemPoolIds : lp_id_t { + P60DOCK_CURRENT_ACU_VCC, + P60DOCK_CURRENT_PDU1_VCC, + P60DOCK_CURRENT_X3_IDLE_VCC, + P60DOCK_CURRENT_PDU2_VCC, + P60DOCK_CURRENT_ACU_VBAT, + P60DOCK_CURRENT_PDU1_VBAT, + P60DOCK_CURRENT_X3_IDLE_VBAT, + P60DOCK_CURRENT_PDU2_VBAT, + P60DOCK_CURRENT_STACK_VBAT, + P60DOCK_CURRENT_STACK_3V3, + P60DOCK_CURRENT_STACK_5V, + P60DOCK_CURRENT_GS3V3, + P60DOCK_CURRENT_GS5V, + P60DOCK_VOLTAGE_ACU_VCC, + P60DOCK_VOLTAGE_PDU1_VCC, + P60DOCK_VOLTAGE_X3_IDLE_VCC, + P60DOCK_VOLTAGE_PDU2_VCC, + P60DOCK_VOLTAGE_ACU_VBAT, + P60DOCK_VOLTAGE_PDU1_VBAT, + P60DOCK_VOLTAGE_X3_IDLE_VBAT, + P60DOCK_VOLTAGE_PDU2_VBAT, + P60DOCK_VOLTAGE_STACK_VBAT, + P60DOCK_VOLTAGE_STACK_3V3, + P60DOCK_VOLTAGE_STACK_5V, + P60DOCK_VOLTAGE_GS3V3, + P60DOCK_VOLTAGE_GS5V, + P60DOCK_OUTPUTENABLE_ACU_VCC, + P60DOCK_OUTPUTENABLE_PDU1_VCC, + P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, + P60DOCK_OUTPUTENABLE_PDU2_VCC, + P60DOCK_OUTPUTENABLE_ACU_VBAT, + P60DOCK_OUTPUTENABLE_PDU1_VBAT, + P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, + P60DOCK_OUTPUTENABLE_PDU2_VBAT, + P60DOCK_OUTPUTENABLE_STACK_VBAT, + P60DOCK_OUTPUTENABLE_STACK_3V3, + P60DOCK_OUTPUTENABLE_STACK_5V, + P60DOCK_OUTPUTENABLE_GS3V3, + P60DOCK_OUTPUTENABLE_GS5V, + P60DOCK_TEMPERATURE_1, + P60DOCK_TEMPERATURE_2, + P60DOCK_BOOT_CAUSE, + P60DOCK_BOOT_CNT, + P60DOCK_UPTIME, + P60DOCK_RESETCAUSE, + P60DOCK_BATT_MODE, + P60DOCK_HEATER_ON, + P60DOCK_CONV_5V_ENABLE_STATUS, + P60DOCK_LATCHUP_ACU_VCC, + P60DOCK_LATCHUP_PDU1_VCC, + P60DOCK_LATCHUP_X3_IDLE_VCC, + P60DOCK_LATCHUP_PDU2_VCC, + P60DOCK_LATCHUP_ACU_VBAT, + P60DOCK_LATCHUP_PDU1_VBAT, + P60DOCK_LATCHUP_X3_IDLE_VBAT, + P60DOCK_LATCHUP_PDU2_VBAT, + P60DOCK_LATCHUP_STACK_VBAT, + P60DOCK_LATCHUP_STACK_3V3, + P60DOCK_LATCHUP_STACK_5V, + P60DOCK_LATCHUP_GS3V3, + P60DOCK_LATCHUP_GS5V, + P60DOCK_VBAT_VALUE, + P60DOCK_VCC_CURRENT_VALUE, + P60DOCK_BATTERY_CURRENT, + P60DOCK_BATTERY_VOLTAGE, + P60DOCK_BATTERY_TEMPERATURE_1, + P60DOCK_BATTERY_TEMPERATURE_2, + P60DOCK_DEVICE_0, + P60DOCK_DEVICE_1, + P60DOCK_DEVICE_2, + P60DOCK_DEVICE_3, + P60DOCK_DEVICE_4, + P60DOCK_DEVICE_5, + P60DOCK_DEVICE_6, + P60DOCK_DEVICE_7, + P60DOCK_DEVICE_0_STATUS, + P60DOCK_DEVICE_1_STATUS, + P60DOCK_DEVICE_2_STATUS, + P60DOCK_DEVICE_3_STATUS, + P60DOCK_DEVICE_4_STATUS, + P60DOCK_DEVICE_5_STATUS, + P60DOCK_DEVICE_6_STATUS, + P60DOCK_DEVICE_7_STATUS, + P60DOCK_DEVICE_TYPE_GROUP, + P60DOCK_DEVICE_STATUS_GROUP, + P60DOCK_DEARM_STATUS, + P60DOCK_WDT_CNT_GND, + P60DOCK_WDT_CNT_I2C, + P60DOCK_WDT_CNT_CAN, + P60DOCK_WDT_CNT_CSP_1, + P60DOCK_WDT_CNT_CSP_2, + P60DOCK_WDT_GND_LEFT, + P60DOCK_WDT_I2C_LEFT, + P60DOCK_WDT_CAN_LEFT, + P60DOCK_WDT_CSP_LEFT_1, + P60DOCK_WDT_CSP_LEFT_2, + P60DOCK_BATT_CHARGE_CURRENT, + P60DOCK_BATT_DISCHARGE_CURRENT, + P60DOCK_ANT6_DEPL, + P60DOCK_AR6_DEPL, - PDU1_CURRENT_OUT_TCS_BOARD_3V3, - PDU1_CURRENT_OUT_SYRLINKS, - PDU1_CURRENT_OUT_STAR_TRACKER, - PDU1_CURRENT_OUT_MGT, - PDU1_CURRENT_OUT_SUS_NOMINAL, - PDU1_CURRENT_OUT_SOLAR_CELL_EXP, - PDU1_CURRENT_OUT_PLOC, - PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, - PDU1_CURRENT_OUT_CHANNEL8, - PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, - PDU1_VOLTAGE_OUT_SYRLINKS, - PDU1_VOLTAGE_OUT_STAR_TRACKER, - PDU1_VOLTAGE_OUT_MGT, - PDU1_VOLTAGE_OUT_SUS_NOMINAL, - PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, - PDU1_VOLTAGE_OUT_PLOC, - PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, - PDU1_VOLTAGE_OUT_CHANNEL8, - PDU1_VCC, - PDU1_VBAT, - PDU1_TEMPERATURE, - PDU1_CONV_EN_1, - PDU1_CONV_EN_2, - PDU1_CONV_EN_3, - PDU1_OUT_EN_TCS_BOARD_3V3, - PDU1_OUT_EN_SYRLINKS, - PDU1_OUT_EN_STAR_TRACKER, - PDU1_OUT_EN_MGT, - PDU1_OUT_EN_SUS_NOMINAL, - PDU1_OUT_EN_SOLAR_CELL_EXP, - PDU1_OUT_EN_PLOC, - PDU1_OUT_EN_ACS_BOARD_SIDE_A, - PDU1_OUT_EN_CHANNEL8, - PDU1_BOOTCAUSE, - PDU1_BOOTCNT, - PDU1_UPTIME, - PDU1_RESETCAUSE, - PDU1_BATT_MODE, - PDU1_LATCHUP_TCS_BOARD_3V3, - PDU1_LATCHUP_SYRLINKS, - PDU1_LATCHUP_STAR_TRACKER, - PDU1_LATCHUP_MGT, - PDU1_LATCHUP_SUS_NOMINAL, - PDU1_LATCHUP_SOLAR_CELL_EXP, - PDU1_LATCHUP_PLOC, - PDU1_LATCHUP_ACS_BOARD_SIDE_A, - PDU1_LATCHUP_CHANNEL8, - PDU1_DEVICE_0, - PDU1_DEVICE_1, - PDU1_DEVICE_2, - PDU1_DEVICE_3, - PDU1_DEVICE_4, - PDU1_DEVICE_5, - PDU1_DEVICE_6, - PDU1_DEVICE_7, - PDU1_DEVICE_0_STATUS, - PDU1_DEVICE_1_STATUS, - PDU1_DEVICE_2_STATUS, - PDU1_DEVICE_3_STATUS, - PDU1_DEVICE_4_STATUS, - PDU1_DEVICE_5_STATUS, - PDU1_DEVICE_6_STATUS, - PDU1_DEVICE_7_STATUS, - PDU1_WDT_CNT_GND, - PDU1_WDT_CNT_I2C, - PDU1_WDT_CNT_CAN, - PDU1_WDT_CNT_CSP1, - PDU1_WDT_CNT_CSP2, - PDU1_WDT_GND_LEFT, - PDU1_WDT_I2C_LEFT, - PDU1_WDT_CAN_LEFT, - PDU1_WDT_CSP_LEFT1, - PDU1_WDT_CSP_LEFT2, + PDU1_CURRENT_OUT_TCS_BOARD_3V3, + PDU1_CURRENT_OUT_SYRLINKS, + PDU1_CURRENT_OUT_STAR_TRACKER, + PDU1_CURRENT_OUT_MGT, + PDU1_CURRENT_OUT_SUS_NOMINAL, + PDU1_CURRENT_OUT_SOLAR_CELL_EXP, + PDU1_CURRENT_OUT_PLOC, + PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, + PDU1_CURRENT_OUT_CHANNEL8, + PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, + PDU1_VOLTAGE_OUT_SYRLINKS, + PDU1_VOLTAGE_OUT_STAR_TRACKER, + PDU1_VOLTAGE_OUT_MGT, + PDU1_VOLTAGE_OUT_SUS_NOMINAL, + PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, + PDU1_VOLTAGE_OUT_PLOC, + PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, + PDU1_VOLTAGE_OUT_CHANNEL8, + PDU1_VCC, + PDU1_VBAT, + PDU1_TEMPERATURE, + PDU1_CONV_EN_1, + PDU1_CONV_EN_2, + PDU1_CONV_EN_3, + PDU1_OUT_EN_TCS_BOARD_3V3, + PDU1_OUT_EN_SYRLINKS, + PDU1_OUT_EN_STAR_TRACKER, + PDU1_OUT_EN_MGT, + PDU1_OUT_EN_SUS_NOMINAL, + PDU1_OUT_EN_SOLAR_CELL_EXP, + PDU1_OUT_EN_PLOC, + PDU1_OUT_EN_ACS_BOARD_SIDE_A, + PDU1_OUT_EN_CHANNEL8, + PDU1_BOOTCAUSE, + PDU1_BOOTCNT, + PDU1_UPTIME, + PDU1_RESETCAUSE, + PDU1_BATT_MODE, + PDU1_LATCHUP_TCS_BOARD_3V3, + PDU1_LATCHUP_SYRLINKS, + PDU1_LATCHUP_STAR_TRACKER, + PDU1_LATCHUP_MGT, + PDU1_LATCHUP_SUS_NOMINAL, + PDU1_LATCHUP_SOLAR_CELL_EXP, + PDU1_LATCHUP_PLOC, + PDU1_LATCHUP_ACS_BOARD_SIDE_A, + PDU1_LATCHUP_CHANNEL8, + PDU1_DEVICE_0, + PDU1_DEVICE_1, + PDU1_DEVICE_2, + PDU1_DEVICE_3, + PDU1_DEVICE_4, + PDU1_DEVICE_5, + PDU1_DEVICE_6, + PDU1_DEVICE_7, + PDU1_DEVICE_0_STATUS, + PDU1_DEVICE_1_STATUS, + PDU1_DEVICE_2_STATUS, + PDU1_DEVICE_3_STATUS, + PDU1_DEVICE_4_STATUS, + PDU1_DEVICE_5_STATUS, + PDU1_DEVICE_6_STATUS, + PDU1_DEVICE_7_STATUS, + PDU1_WDT_CNT_GND, + PDU1_WDT_CNT_I2C, + PDU1_WDT_CNT_CAN, + PDU1_WDT_CNT_CSP1, + PDU1_WDT_CNT_CSP2, + PDU1_WDT_GND_LEFT, + PDU1_WDT_I2C_LEFT, + PDU1_WDT_CAN_LEFT, + PDU1_WDT_CSP_LEFT1, + PDU1_WDT_CSP_LEFT2, - /** PDU2 Ids */ - PDU2_CURRENT_OUT_Q7S, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, - PDU2_CURRENT_OUT_RW, - PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, - PDU2_CURRENT_OUT_SUS_REDUNDANT, - PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, - PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, - PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, - PDU2_CURRENT_OUT_PAYLOAD_CAMERA, - PDU2_VOLTAGE_OUT_Q7S, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, - PDU2_VOLTAGE_OUT_RW, - PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, - PDU2_VOLTAGE_OUT_SUS_REDUNDANT, - PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, - PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, - PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, - PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, - PDU2_VCC, - PDU2_VBAT, - PDU2_TEMPERATURE, - PDU2_CONV_EN_1, - PDU2_CONV_EN_2, - PDU2_CONV_EN_3, - PDU2_OUT_EN_Q7S, - PDU2_OUT_EN_PAYLOAD_PCDU_CH1, - PDU2_OUT_EN_RW, - PDU2_OUT_EN_TCS_BOARD_HEATER_IN, - PDU2_OUT_EN_SUS_REDUNDANT, - PDU2_OUT_EN_DEPLOYMENT_MECHANISM, - PDU2_OUT_EN_PAYLOAD_PCDU_CH6, - PDU2_OUT_EN_ACS_BOARD_SIDE_B, - PDU2_OUT_EN_PAYLOAD_CAMERA, - PDU2_BOOTCAUSE, - PDU2_BOOTCNT, - PDU2_UPTIME, - PDU2_RESETCAUSE, - PDU2_BATT_MODE, - PDU2_LATCHUP_Q7S, - PDU2_LATCHUP_PAYLOAD_PCDU_CH1, - PDU2_LATCHUP_RW, - PDU2_LATCHUP_TCS_BOARD_HEATER_IN, - PDU2_LATCHUP_SUS_REDUNDANT, - PDU2_LATCHUP_DEPLOYMENT_MECHANISM, - PDU2_LATCHUP_PAYLOAD_PCDU_CH6, - PDU2_LATCHUP_ACS_BOARD_SIDE_B, - PDU2_LATCHUP_PAYLOAD_CAMERA, - PDU2_DEVICE_0, - PDU2_DEVICE_1, - PDU2_DEVICE_2, - PDU2_DEVICE_3, - PDU2_DEVICE_4, - PDU2_DEVICE_5, - PDU2_DEVICE_6, - PDU2_DEVICE_7, - PDU2_DEVICE_0_STATUS, - PDU2_DEVICE_1_STATUS, - PDU2_DEVICE_2_STATUS, - PDU2_DEVICE_3_STATUS, - PDU2_DEVICE_4_STATUS, - PDU2_DEVICE_5_STATUS, - PDU2_DEVICE_6_STATUS, - PDU2_DEVICE_7_STATUS, - PDU2_WDT_CNT_GND, - PDU2_WDT_CNT_I2C, - PDU2_WDT_CNT_CAN, - PDU2_WDT_CNT_CSP1, - PDU2_WDT_CNT_CSP2, - PDU2_WDT_GND_LEFT, - PDU2_WDT_I2C_LEFT, - PDU2_WDT_CAN_LEFT, - PDU2_WDT_CSP_LEFT1, - PDU2_WDT_CSP_LEFT2, + /** PDU2 Ids */ + PDU2_CURRENT_OUT_Q7S, + PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, + PDU2_CURRENT_OUT_RW, + PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, + PDU2_CURRENT_OUT_SUS_REDUNDANT, + PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, + PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, + PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, + PDU2_CURRENT_OUT_PAYLOAD_CAMERA, + PDU2_VOLTAGE_OUT_Q7S, + PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, + PDU2_VOLTAGE_OUT_RW, + PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, + PDU2_VOLTAGE_OUT_SUS_REDUNDANT, + PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, + PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, + PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, + PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, + PDU2_VCC, + PDU2_VBAT, + PDU2_TEMPERATURE, + PDU2_CONV_EN_1, + PDU2_CONV_EN_2, + PDU2_CONV_EN_3, + PDU2_OUT_EN_Q7S, + PDU2_OUT_EN_PAYLOAD_PCDU_CH1, + PDU2_OUT_EN_RW, + PDU2_OUT_EN_TCS_BOARD_HEATER_IN, + PDU2_OUT_EN_SUS_REDUNDANT, + PDU2_OUT_EN_DEPLOYMENT_MECHANISM, + PDU2_OUT_EN_PAYLOAD_PCDU_CH6, + PDU2_OUT_EN_ACS_BOARD_SIDE_B, + PDU2_OUT_EN_PAYLOAD_CAMERA, + PDU2_BOOTCAUSE, + PDU2_BOOTCNT, + PDU2_UPTIME, + PDU2_RESETCAUSE, + PDU2_BATT_MODE, + PDU2_LATCHUP_Q7S, + PDU2_LATCHUP_PAYLOAD_PCDU_CH1, + PDU2_LATCHUP_RW, + PDU2_LATCHUP_TCS_BOARD_HEATER_IN, + PDU2_LATCHUP_SUS_REDUNDANT, + PDU2_LATCHUP_DEPLOYMENT_MECHANISM, + PDU2_LATCHUP_PAYLOAD_PCDU_CH6, + PDU2_LATCHUP_ACS_BOARD_SIDE_B, + PDU2_LATCHUP_PAYLOAD_CAMERA, + PDU2_DEVICE_0, + PDU2_DEVICE_1, + PDU2_DEVICE_2, + PDU2_DEVICE_3, + PDU2_DEVICE_4, + PDU2_DEVICE_5, + PDU2_DEVICE_6, + PDU2_DEVICE_7, + PDU2_DEVICE_0_STATUS, + PDU2_DEVICE_1_STATUS, + PDU2_DEVICE_2_STATUS, + PDU2_DEVICE_3_STATUS, + PDU2_DEVICE_4_STATUS, + PDU2_DEVICE_5_STATUS, + PDU2_DEVICE_6_STATUS, + PDU2_DEVICE_7_STATUS, + PDU2_WDT_CNT_GND, + PDU2_WDT_CNT_I2C, + PDU2_WDT_CNT_CAN, + PDU2_WDT_CNT_CSP1, + PDU2_WDT_CNT_CSP2, + PDU2_WDT_GND_LEFT, + PDU2_WDT_I2C_LEFT, + PDU2_WDT_CAN_LEFT, + PDU2_WDT_CSP_LEFT1, + PDU2_WDT_CSP_LEFT2, - /** ACU Ids */ - ACU_CURRENT_IN_CHANNEL0, - ACU_CURRENT_IN_CHANNEL1, - ACU_CURRENT_IN_CHANNEL2, - ACU_CURRENT_IN_CHANNEL3, - ACU_CURRENT_IN_CHANNEL4, - ACU_CURRENT_IN_CHANNEL5, - ACU_VOLTAGE_IN_CHANNEL0, - ACU_VOLTAGE_IN_CHANNEL1, - ACU_VOLTAGE_IN_CHANNEL2, - ACU_VOLTAGE_IN_CHANNEL3, - ACU_VOLTAGE_IN_CHANNEL4, - ACU_VOLTAGE_IN_CHANNEL5, - ACU_VCC, - ACU_VBAT, - ACU_TEMPERATURE_1, - ACU_TEMPERATURE_2, - ACU_TEMPERATURE_3, - ACU_MPPT_MODE, - ACU_VBOOST_CHANNEL0, - ACU_VBOOST_CHANNEL1, - ACU_VBOOST_CHANNEL2, - ACU_VBOOST_CHANNEL3, - ACU_VBOOST_CHANNEL4, - ACU_VBOOST_CHANNEL5, - ACU_POWER_CHANNEL0, - ACU_POWER_CHANNEL1, - ACU_POWER_CHANNEL2, - ACU_POWER_CHANNEL3, - ACU_POWER_CHANNEL4, - ACU_POWER_CHANNEL5, - ACU_DAC_EN_0, - ACU_DAC_EN_1, - ACU_DAC_EN_2, - ACU_DAC_RAW_0, - ACU_DAC_RAW_1, - ACU_DAC_RAW_2, - ACU_DAC_RAW_3, - ACU_DAC_RAW_4, - ACU_DAC_RAW_5, - ACU_BOOTCAUSE, - ACU_BOOTCNT, - ACU_UPTIME, - ACU_RESET_CAUSE, - ACU_MPPT_TIME, - ACU_MPPT_PERIOD, - ACU_DEVICE_0, - ACU_DEVICE_1, - ACU_DEVICE_2, - ACU_DEVICE_3, - ACU_DEVICE_4, - ACU_DEVICE_5, - ACU_DEVICE_6, - ACU_DEVICE_7, - ACU_DEVICE_0_STATUS, - ACU_DEVICE_1_STATUS, - ACU_DEVICE_2_STATUS, - ACU_DEVICE_3_STATUS, - ACU_DEVICE_4_STATUS, - ACU_DEVICE_5_STATUS, - ACU_DEVICE_6_STATUS, - ACU_DEVICE_7_STATUS, - ACU_WDT_CNT_GND, - ACU_WDT_GND_LEFT + /** ACU Ids */ + ACU_CURRENT_IN_CHANNEL0, + ACU_CURRENT_IN_CHANNEL1, + ACU_CURRENT_IN_CHANNEL2, + ACU_CURRENT_IN_CHANNEL3, + ACU_CURRENT_IN_CHANNEL4, + ACU_CURRENT_IN_CHANNEL5, + ACU_VOLTAGE_IN_CHANNEL0, + ACU_VOLTAGE_IN_CHANNEL1, + ACU_VOLTAGE_IN_CHANNEL2, + ACU_VOLTAGE_IN_CHANNEL3, + ACU_VOLTAGE_IN_CHANNEL4, + ACU_VOLTAGE_IN_CHANNEL5, + ACU_VCC, + ACU_VBAT, + ACU_TEMPERATURE_1, + ACU_TEMPERATURE_2, + ACU_TEMPERATURE_3, + ACU_MPPT_MODE, + ACU_VBOOST_CHANNEL0, + ACU_VBOOST_CHANNEL1, + ACU_VBOOST_CHANNEL2, + ACU_VBOOST_CHANNEL3, + ACU_VBOOST_CHANNEL4, + ACU_VBOOST_CHANNEL5, + ACU_POWER_CHANNEL0, + ACU_POWER_CHANNEL1, + ACU_POWER_CHANNEL2, + ACU_POWER_CHANNEL3, + ACU_POWER_CHANNEL4, + ACU_POWER_CHANNEL5, + ACU_DAC_EN_0, + ACU_DAC_EN_1, + ACU_DAC_EN_2, + ACU_DAC_RAW_0, + ACU_DAC_RAW_1, + ACU_DAC_RAW_2, + ACU_DAC_RAW_3, + ACU_DAC_RAW_4, + ACU_DAC_RAW_5, + ACU_BOOTCAUSE, + ACU_BOOTCNT, + ACU_UPTIME, + ACU_RESET_CAUSE, + ACU_MPPT_TIME, + ACU_MPPT_PERIOD, + ACU_DEVICE_0, + ACU_DEVICE_1, + ACU_DEVICE_2, + ACU_DEVICE_3, + ACU_DEVICE_4, + ACU_DEVICE_5, + ACU_DEVICE_6, + ACU_DEVICE_7, + ACU_DEVICE_0_STATUS, + ACU_DEVICE_1_STATUS, + ACU_DEVICE_2_STATUS, + ACU_DEVICE_3_STATUS, + ACU_DEVICE_4_STATUS, + ACU_DEVICE_5_STATUS, + ACU_DEVICE_6_STATUS, + ACU_DEVICE_7_STATUS, + ACU_WDT_CNT_GND, + ACU_WDT_GND_LEFT }; } - namespace P60Dock { /** Max reply size reached when requesting full hk table */ @@ -386,240 +385,221 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 407; * The GS port and X3 are not required for EIVE. X3 is another slot on the P60 dock and * GS is required for a module from Gomspace which is not used. */ -class HkTableDataset: - public StaticLocalDataSet { - public: +class HkTableDataset : public StaticLocalDataSet { + public: + HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_ACU_VCC, this); + lp_var_t currentPdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU1_VCC, this); + lp_var_t currentX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_X3_IDLE_VCC, this); + lp_var_t currentPdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU2_VCC, this); + lp_var_t currentAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_ACU_VBAT, this); + lp_var_t currentPdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU1_VBAT, this); + lp_var_t currentX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, this); + lp_var_t currentPdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_PDU2_VBAT, this); + lp_var_t currentStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_VBAT, this); + lp_var_t currentStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_3V3, this); + lp_var_t currentStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_STACK_5V, this); + lp_var_t currentGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_GS3V3, this); + lp_var_t currentGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_CURRENT_GS5V, this); - /** Measured output currents */ - lp_var_t currentAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_ACU_VCC, this); - lp_var_t currentPdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU1_VCC, this); - lp_var_t currentX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_X3_IDLE_VCC, this); - lp_var_t currentPdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU2_VCC, this); - lp_var_t currentAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_ACU_VBAT, this); - lp_var_t currentPdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU1_VBAT, this); - lp_var_t currentX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_X3_IDLE_VBAT, this); - lp_var_t currentPdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_PDU2_VBAT, this); - lp_var_t currentStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_VBAT, this); - lp_var_t currentStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_3V3, this); - lp_var_t currentStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_STACK_5V, this); - lp_var_t currentGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_GS3V3, this); - lp_var_t currentGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_CURRENT_GS5V, this); + /** Measured output voltages */ + lp_var_t voltageAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_ACU_VCC, this); + lp_var_t voltagePdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU1_VCC, this); + lp_var_t voltageX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, this); + lp_var_t voltagePdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU2_VCC, this); + lp_var_t voltageAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_ACU_VBAT, this); + lp_var_t voltagePdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU1_VBAT, this); + lp_var_t voltageX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, this); + lp_var_t voltagePdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_PDU2_VBAT, this); + lp_var_t voltageStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_VBAT, this); + lp_var_t voltageStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_3V3, this); + lp_var_t voltageStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_STACK_5V, this); + lp_var_t voltageGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_GS3V3, this); + lp_var_t voltageGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_VOLTAGE_GS5V, this); - /** Measured output voltages */ - lp_var_t voltageAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_ACU_VCC, this); - lp_var_t voltagePdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU1_VCC, this); - lp_var_t voltageX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_X3_IDLE_VCC, this); - lp_var_t voltagePdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU2_VCC, this); - lp_var_t voltageAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_ACU_VBAT, this); - lp_var_t voltagePdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU1_VBAT, this); - lp_var_t voltageX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_X3_IDLE_VBAT, this); - lp_var_t voltagePdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_PDU2_VBAT, this); - lp_var_t voltageStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_VBAT, this); - lp_var_t voltageStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_3V3, this); - lp_var_t voltageStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_STACK_5V, this); - lp_var_t voltageGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_GS3V3, this); - lp_var_t voltageGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_VOLTAGE_GS5V, this); + /** Output enable states */ + lp_var_t outputEnableStateAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, this); + lp_var_t outputEnableStatePdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, this); + lp_var_t outputEnableStateX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, this); + lp_var_t outputEnableStatePdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, this); + lp_var_t outputEnableStateAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, this); + lp_var_t outputEnableStatePdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, this); + lp_var_t outputEnableStateX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, this); + lp_var_t outputEnableStatePdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, this); + lp_var_t outputEnableStateStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, this); + lp_var_t outputEnableStateStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, this); + lp_var_t outputEnableStateStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_STACK_5V, this); + lp_var_t outputEnableStateGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_GS3V3, this); + lp_var_t outputEnableStateGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_OUTPUTENABLE_GS5V, this); - /** Output enable states */ - lp_var_t outputEnableStateAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_ACU_VCC, this); - lp_var_t outputEnableStatePdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU1_VCC, this); - lp_var_t outputEnableStateX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VCC, this); - lp_var_t outputEnableStatePdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU2_VCC, this); - lp_var_t outputEnableStateAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_ACU_VBAT, this); - lp_var_t outputEnableStatePdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU1_VBAT, this); - lp_var_t outputEnableStateX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_X3_IDLE_VBAT, this); - lp_var_t outputEnableStatePdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_PDU2_VBAT, this); - lp_var_t outputEnableStateStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_VBAT, this); - lp_var_t outputEnableStateStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_3V3, this); - lp_var_t outputEnableStateStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_STACK_5V, this); - lp_var_t outputEnableStateGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_GS3V3, this); - lp_var_t outputEnableStateGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_OUTPUTENABLE_GS5V, this); + lp_var_t temperature1 = + lp_var_t(sid.objectId, P60System::P60DOCK_TEMPERATURE_1, this); + lp_var_t temperature2 = + lp_var_t(sid.objectId, P60System::P60DOCK_TEMPERATURE_2, this); - lp_var_t temperature1 = lp_var_t(sid.objectId, - P60System::P60DOCK_TEMPERATURE_1, this); - lp_var_t temperature2 = lp_var_t(sid.objectId, - P60System::P60DOCK_TEMPERATURE_2, this); + lp_var_t bootcause = + lp_var_t(sid.objectId, P60System::P60DOCK_BOOT_CAUSE, this); + lp_var_t bootCount = + lp_var_t(sid.objectId, P60System::P60DOCK_BOOT_CNT, this); + lp_var_t uptime = lp_var_t(sid.objectId, P60System::P60DOCK_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::P60DOCK_RESETCAUSE, this); + lp_var_t battMode = lp_var_t(sid.objectId, P60System::P60DOCK_BATT_MODE, this); + /** Battery heater control only possible on BP4 packs */ + lp_var_t heaterOn = lp_var_t(sid.objectId, P60System::P60DOCK_HEATER_ON, this); + lp_var_t converter5VStatus = + lp_var_t(sid.objectId, P60System::P60DOCK_CONV_5V_ENABLE_STATUS, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::P60DOCK_BOOT_CAUSE, this); - lp_var_t bootCount = lp_var_t(sid.objectId, - P60System::P60DOCK_BOOT_CNT, this); - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::P60DOCK_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::P60DOCK_RESETCAUSE, this); - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_MODE, this); - /** Battery heater control only possible on BP4 packs */ - lp_var_t heaterOn = lp_var_t(sid.objectId, - P60System::P60DOCK_HEATER_ON, this); - lp_var_t converter5VStatus = lp_var_t(sid.objectId, - P60System::P60DOCK_CONV_5V_ENABLE_STATUS, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsAcuVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_ACU_VCC, this); + lp_var_t latchupsPdu1Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU1_VCC, this); + lp_var_t latchupsX3IdleVcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, this); + lp_var_t latchupsPdu2Vcc = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU2_VCC, this); + lp_var_t latchupsAcuVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_ACU_VBAT, this); + lp_var_t latchupsPdu1Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU1_VBAT, this); + lp_var_t latchupsX3IdleVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, this); + lp_var_t latchupsPdu2Vbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_PDU2_VBAT, this); + lp_var_t latchupsStackVbat = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_VBAT, this); + lp_var_t latchupsStack3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_3V3, this); + lp_var_t latchupsStack5V = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_STACK_5V, this); + lp_var_t latchupsGS3V3 = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_GS3V3, this); + lp_var_t latchupsGS5V = + lp_var_t(sid.objectId, P60System::P60DOCK_LATCHUP_GS5V, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsAcuVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_ACU_VCC, this); - lp_var_t latchupsPdu1Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU1_VCC, this); - lp_var_t latchupsX3IdleVcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_X3_IDLE_VCC, this); - lp_var_t latchupsPdu2Vcc = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU2_VCC, this); - lp_var_t latchupsAcuVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_ACU_VBAT, this); - lp_var_t latchupsPdu1Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU1_VBAT, this); - lp_var_t latchupsX3IdleVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_X3_IDLE_VBAT, this); - lp_var_t latchupsPdu2Vbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_PDU2_VBAT, this); - lp_var_t latchupsStackVbat = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_VBAT, this); - lp_var_t latchupsStack3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_3V3, this); - lp_var_t latchupsStack5V = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_STACK_5V, this); - lp_var_t latchupsGS3V3 = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_GS3V3, this); - lp_var_t latchupsGS5V = lp_var_t(sid.objectId, - P60System::P60DOCK_LATCHUP_GS5V, this); + lp_var_t vbatVoltageValue = + lp_var_t(sid.objectId, P60System::P60DOCK_VBAT_VALUE, this); + lp_var_t vccCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_VCC_CURRENT_VALUE, this); + lp_var_t batteryCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_CURRENT, this); + lp_var_t batteryVoltage = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_VOLTAGE, this); - lp_var_t vbatVoltageValue = lp_var_t(sid.objectId, - P60System::P60DOCK_VBAT_VALUE, this); - lp_var_t vccCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_VCC_CURRENT_VALUE, this); - lp_var_t batteryCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_CURRENT, this); - lp_var_t batteryVoltage = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_VOLTAGE, this); + lp_var_t batteryTemperature1 = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_TEMPERATURE_1, this); + lp_var_t batteryTemperature2 = + lp_var_t(sid.objectId, P60System::P60DOCK_BATTERY_TEMPERATURE_2, this); - lp_var_t batteryTemperature1 = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_TEMPERATURE_1, this); - lp_var_t batteryTemperature2 = lp_var_t(sid.objectId, - P60System::P60DOCK_BATTERY_TEMPERATURE_2, this); + lp_var_t device0 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_7, this); - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_7, this); + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::P60DOCK_DEVICE_7_STATUS, this); - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::P60DOCK_DEVICE_7_STATUS, this); + lp_var_t dearmStatus = + lp_var_t(sid.objectId, P60System::P60DOCK_DEARM_STATUS, this); - lp_var_t dearmStatus = lp_var_t(sid.objectId, - P60System::P60DOCK_DEARM_STATUS, this); + /** Number of reboots due to gnd, i2c, csp watchdog timeout */ + lp_var_t wdtCntGnd = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_GND, this); + lp_var_t wdtCntI2c = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_I2C, this); + lp_var_t wdtCntCan = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CAN, this); + lp_var_t wdtCntCsp1 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CSP_1, this); + lp_var_t wdtCntCsp2 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CNT_CSP_2, this); - /** Number of reboots due to gnd, i2c, csp watchdog timeout */ - lp_var_t wdtCntGnd = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_GND, this); - lp_var_t wdtCntI2c = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_I2C, this); - lp_var_t wdtCntCan = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CAN, this); - lp_var_t wdtCntCsp1 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CSP_1, this); - lp_var_t wdtCntCsp2 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CNT_CSP_2, this); - - lp_var_t wdtGndLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_GND_LEFT, this); - lp_var_t wdtI2cLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_I2C_LEFT, this); - lp_var_t wdtCanLeft = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CAN_LEFT, this); - lp_var_t wdtCspLeft1 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CSP_LEFT_1, this); - lp_var_t wdtCspLeft2 = lp_var_t(sid.objectId, - P60System::P60DOCK_WDT_CSP_LEFT_2, this); - lp_var_t batteryChargeCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_CHARGE_CURRENT, this); - lp_var_t batteryDischargeCurrent = lp_var_t(sid.objectId, - P60System::P60DOCK_BATT_DISCHARGE_CURRENT, this); - lp_var_t ant6Depl = lp_var_t(sid.objectId, - P60System::P60DOCK_ANT6_DEPL, this); - lp_var_t ar6Depl = lp_var_t(sid.objectId, - P60System::P60DOCK_AR6_DEPL, this); + lp_var_t wdtGndLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_GND_LEFT, this); + lp_var_t wdtI2cLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_I2C_LEFT, this); + lp_var_t wdtCanLeft = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CAN_LEFT, this); + lp_var_t wdtCspLeft1 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CSP_LEFT_1, this); + lp_var_t wdtCspLeft2 = + lp_var_t(sid.objectId, P60System::P60DOCK_WDT_CSP_LEFT_2, this); + lp_var_t batteryChargeCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATT_CHARGE_CURRENT, this); + lp_var_t batteryDischargeCurrent = + lp_var_t(sid.objectId, P60System::P60DOCK_BATT_DISCHARGE_CURRENT, this); + lp_var_t ant6Depl = lp_var_t(sid.objectId, P60System::P60DOCK_ANT6_DEPL, this); + lp_var_t ar6Depl = lp_var_t(sid.objectId, P60System::P60DOCK_AR6_DEPL, this); }; -} - +} // namespace P60Dock /** * @brief Constants common for both PDU1 and PDU2. */ -namespace PDU{ +namespace PDU { /** When retrieving full configuration parameter table */ static const uint16_t MAX_REPLY_LENGTH = 318; static const uint16_t MAX_CONFIGTABLE_ADDRESS = 316; @@ -627,11 +607,10 @@ static const uint16_t MAX_HKTABLE_ADDRESS = 141; /** The size of the csp reply containing the housekeeping table data */ static const uint16_t HK_TABLE_REPLY_SIZE = 303; static const uint8_t HK_TABLE_ENTRIES = 73; -} - +} // namespace PDU namespace PDU1 { -static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 +static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 /** * Addresses within configuration table to enable or disable output channels. Refer also to * gs-man-nanopower-p60-pdu-200.pdf on page 16. @@ -649,194 +628,174 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x56; /** * @brief This class defines a dataset for the hk table of the PDU1. */ -class PDU1HkTableDataset : - public StaticLocalDataSet { - public: +class PDU1HkTableDataset : public StaticLocalDataSet { + public: + PDU1HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - PDU1HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + PDU1HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - PDU1HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentOutTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, this); + lp_var_t currentOutSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SYRLINKS, this); + lp_var_t currentOutStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_STAR_TRACKER, this); + lp_var_t currentOutMGT = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_MGT, this); + lp_var_t currentOutSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, this); + lp_var_t currentOutSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, this); + lp_var_t currentOutPLOC = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_PLOC, this); + lp_var_t currentOutACSBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, this); + lp_var_t currentOutChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_CURRENT_OUT_CHANNEL8, this); + /** Measured voltage of output channels */ + lp_var_t voltageOutTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, this); + lp_var_t voltageOutSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SYRLINKS, this); + lp_var_t voltageOutStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, this); + lp_var_t voltageOutMGT = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_MGT, this); + lp_var_t voltageOutSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, this); + lp_var_t voltageOutSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, this); + lp_var_t voltageOutPLOC = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_PLOC, this); + lp_var_t voltageOutACSBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, this); + lp_var_t voltageOutChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_VOLTAGE_OUT_CHANNEL8, this); + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, P60System::PDU1_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, P60System::PDU1_VBAT, this); + lp_var_t temperature = + lp_var_t(sid.objectId, P60System::PDU1_TEMPERATURE, this); + /** Output converter enable status */ + lp_var_t converterEnable1 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_1, this); + lp_var_t converterEnable2 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_2, this); + lp_var_t converterEnable3 = + lp_var_t(sid.objectId, P60System::PDU1_CONV_EN_3, this); - /** Measured output currents */ - lp_var_t currentOutTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_TCS_BOARD_3V3, this); - lp_var_t currentOutSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SYRLINKS, this); - lp_var_t currentOutStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_STAR_TRACKER, this); - lp_var_t currentOutMGT = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_MGT, this); - lp_var_t currentOutSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SUS_NOMINAL, this); - lp_var_t currentOutSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_SOLAR_CELL_EXP, this); - lp_var_t currentOutPLOC = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_PLOC, this); - lp_var_t currentOutACSBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t currentOutChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_CURRENT_OUT_CHANNEL8, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_TCS_BOARD_3V3, this); - lp_var_t voltageOutSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SYRLINKS, this); - lp_var_t voltageOutStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_STAR_TRACKER, this); - lp_var_t voltageOutMGT = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_MGT, this); - lp_var_t voltageOutSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SUS_NOMINAL, this); - lp_var_t voltageOutSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_SOLAR_CELL_EXP, this); - lp_var_t voltageOutPLOC = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_PLOC, this); - lp_var_t voltageOutACSBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_ACS_BOARD_SIDE_A, this); - lp_var_t voltageOutChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_VOLTAGE_OUT_CHANNEL8, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::PDU1_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::PDU1_VBAT, this); - lp_var_t temperature = lp_var_t(sid.objectId, - P60System::PDU1_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_1, this); - lp_var_t converterEnable2 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_2, this); - lp_var_t converterEnable3 = lp_var_t(sid.objectId, - P60System::PDU1_CONV_EN_3, this); + /** Output channels enable status */ + lp_var_t outEnabledTCSBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_TCS_BOARD_3V3, this); + lp_var_t outEnabledSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SYRLINKS, this); + lp_var_t outEnabledStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_STAR_TRACKER, this); + lp_var_t outEnabledMGT = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_MGT, this); + lp_var_t outEnabledSUSNominal = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SUS_NOMINAL, this); + lp_var_t outEnabledSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, this); + lp_var_t outEnabledPLOC = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_PLOC, this); + lp_var_t outEnabledAcsBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, this); + lp_var_t outEnabledChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_OUT_EN_CHANNEL8, this); + lp_var_t bootcause = lp_var_t(sid.objectId, P60System::PDU1_BOOTCAUSE, this); + /** Number of reboots */ + lp_var_t bootcount = lp_var_t(sid.objectId, P60System::PDU1_BOOTCNT, this); + /** Uptime in seconds */ + lp_var_t uptime = lp_var_t(sid.objectId, P60System::PDU1_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::PDU1_RESETCAUSE, this); + /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ + lp_var_t battMode = lp_var_t(sid.objectId, P60System::PDU1_BATT_MODE, this); - /** Output channels enable status */ - lp_var_t outEnabledTCSBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_TCS_BOARD_3V3, this); - lp_var_t outEnabledSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SYRLINKS, this); - lp_var_t outEnabledStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_STAR_TRACKER, this); - lp_var_t outEnabledMGT = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_MGT, this); - lp_var_t outEnabledSUSNominal = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SUS_NOMINAL, this); - lp_var_t outEnabledSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_SOLAR_CELL_EXP, this); - lp_var_t outEnabledPLOC = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_PLOC, this); - lp_var_t outEnabledAcsBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_ACS_BOARD_SIDE_A, this); - lp_var_t outEnabledChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_OUT_EN_CHANNEL8, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::PDU1_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = lp_var_t(sid.objectId, - P60System::PDU1_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::PDU1_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::PDU1_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::PDU1_BATT_MODE, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsTcsBoard3V3 = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_TCS_BOARD_3V3, this); + lp_var_t latchupsSyrlinks = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SYRLINKS, this); + lp_var_t latchupsStarTracker = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_STAR_TRACKER, this); + lp_var_t latchupsMgt = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_MGT, this); + lp_var_t latchupsSusNominal = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SUS_NOMINAL, this); + lp_var_t latchupsSolarCellExp = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, this); + lp_var_t latchupsPloc = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_PLOC, this); + lp_var_t latchupsAcsBoardSideA = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, this); + lp_var_t latchupsChannel8 = + lp_var_t(sid.objectId, P60System::PDU1_LATCHUP_CHANNEL8, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsTcsBoard3V3 = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_TCS_BOARD_3V3, this); - lp_var_t latchupsSyrlinks = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SYRLINKS, this); - lp_var_t latchupsStarTracker = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_STAR_TRACKER, this); - lp_var_t latchupsMgt = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_MGT, this); - lp_var_t latchupsSusNominal = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SUS_NOMINAL, this); - lp_var_t latchupsSolarCellExp = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_SOLAR_CELL_EXP, this); - lp_var_t latchupsPloc = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_PLOC, this); - lp_var_t latchupsAcsBoardSideA = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_ACS_BOARD_SIDE_A, this); - lp_var_t latchupsChannel8 = lp_var_t(sid.objectId, - P60System::PDU1_LATCHUP_CHANNEL8, this); + /** + * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is + * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. + */ + lp_var_t device0 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::PDU1_DEVICE_7, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::PDU1_DEVICE_7_STATUS, this); - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::PDU1_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CAN_LEFT, this); - /** CSP watchdogs remaining pings before rebooting. */ - lp_var_t csp2WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CSP_LEFT1, this); - lp_var_t csp1WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU1_WDT_CSP_LEFT2, this); + /** Number of reboots triggered by the ground watchdog */ + lp_var_t gndWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_GND, this); + /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ + lp_var_t i2cWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_I2C, this); + /** Number of reboots triggered through the CAN watchdog */ + lp_var_t canWdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CAN, this); + /** Number of reboots triggered through the CSP watchdog */ + lp_var_t csp1WdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CSP1, this); + lp_var_t csp2WdtReboots = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CNT_CSP2, this); + /** Ground watchdog remaining seconds before rebooting */ + lp_var_t groundWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_GND_LEFT, this); + /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ + lp_var_t i2cWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_I2C_LEFT, this); + /** CAN watchdog remaining seconds before rebooting. */ + lp_var_t canWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CAN_LEFT, this); + /** CSP watchdogs remaining pings before rebooting. */ + lp_var_t csp2WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CSP_LEFT1, this); + lp_var_t csp1WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU1_WDT_CSP_LEFT2, this); }; -} - +} // namespace PDU1 namespace PDU2 { static const uint32_t HK_TABLE_DATA_SET_ID = 0x2; @@ -857,194 +816,174 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA = 0x50; /** * @brief This class defines a dataset for the hk table of the PDU2. */ -class PDU2HkTableDataset: - public StaticLocalDataSet { - public: +class PDU2HkTableDataset : public StaticLocalDataSet { + public: + PDU2HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - PDU2HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + PDU2HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - PDU2HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + /** Measured output currents */ + lp_var_t currentOutQ7S = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_Q7S, this); + lp_var_t currentOutPayloadPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, this); + lp_var_t currentOutReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_RW, this); + lp_var_t currentOutTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, this); + lp_var_t currentOutSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, this); + lp_var_t currentOutDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, this); + lp_var_t currentOutPayloadPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, this); + lp_var_t currentOutACSBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, this); + lp_var_t currentOutPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, this); + /** Measured voltage of output channels */ + lp_var_t voltageOutQ7S = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_Q7S, this); + lp_var_t voltageOutPayloadPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, this); + lp_var_t voltageOutReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_RW, this); + lp_var_t voltageOutTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, this); + lp_var_t voltageOutSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, this); + lp_var_t voltageOutDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, this); + lp_var_t voltageOutPayloadPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, this); + lp_var_t voltageOutACSBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, this); + lp_var_t voltageOutPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, this); + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, P60System::PDU2_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, P60System::PDU2_VBAT, this); + lp_var_t temperature = + lp_var_t(sid.objectId, P60System::PDU2_TEMPERATURE, this); + /** Output converter enable status */ + lp_var_t converterEnable1 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_1, this); + lp_var_t converterEnable2 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_2, this); + lp_var_t converterEnable3 = + lp_var_t(sid.objectId, P60System::PDU2_CONV_EN_3, this); + /** Output channels enable status */ + lp_var_t outEnabledQ7S = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_Q7S, this); + lp_var_t outEnabledPlPCDUCh1 = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, this); + lp_var_t outEnabledReactionWheels = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_RW, this); + lp_var_t outEnabledTCSBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, this); + lp_var_t outEnabledSUSRedundant = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_SUS_REDUNDANT, this); + lp_var_t outEnabledDeplMechanism = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, this); + lp_var_t outEnabledPlPCDUCh6 = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, this); + lp_var_t outEnabledAcsBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, this); + lp_var_t outEnabledPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, this); - /** Measured output currents */ - lp_var_t currentOutQ7S = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_Q7S, this); - lp_var_t currentOutPayloadPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t currentOutReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_RW, this); - lp_var_t currentOutTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t currentOutSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_SUS_REDUNDANT, this); - lp_var_t currentOutDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t currentOutPayloadPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t currentOutACSBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t currentOutPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_CURRENT_OUT_PAYLOAD_CAMERA, this); - /** Measured voltage of output channels */ - lp_var_t voltageOutQ7S = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_Q7S, this); - lp_var_t voltageOutPayloadPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH1, this); - lp_var_t voltageOutReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_RW, this); - lp_var_t voltageOutTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_TCS_BOARD_HEATER_IN, this); - lp_var_t voltageOutSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_SUS_REDUNDANT, this); - lp_var_t voltageOutDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_DEPLOYMENT_MECHANISM, this); - lp_var_t voltageOutPayloadPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_PCDU_CH6, this); - lp_var_t voltageOutACSBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_ACS_BOARD_SIDE_B, this); - lp_var_t voltageOutPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_VOLTAGE_OUT_PAYLOAD_CAMERA, this); - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::PDU2_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::PDU2_VBAT, this); - lp_var_t temperature = lp_var_t(sid.objectId, - P60System::PDU2_TEMPERATURE, this); - /** Output converter enable status */ - lp_var_t converterEnable1 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_1, this); - lp_var_t converterEnable2 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_2, this); - lp_var_t converterEnable3 = lp_var_t(sid.objectId, - P60System::PDU2_CONV_EN_3, this); - /** Output channels enable status */ - lp_var_t outEnabledQ7S = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_Q7S, this); - lp_var_t outEnabledPlPCDUCh1 = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH1, this); - lp_var_t outEnabledReactionWheels = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_RW, this); - lp_var_t outEnabledTCSBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_TCS_BOARD_HEATER_IN, this); - lp_var_t outEnabledSUSRedundant = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_SUS_REDUNDANT, this); - lp_var_t outEnabledDeplMechanism = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_DEPLOYMENT_MECHANISM, this); - lp_var_t outEnabledPlPCDUCh6 = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_PCDU_CH6, this); - lp_var_t outEnabledAcsBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_ACS_BOARD_SIDE_B, this); - lp_var_t outEnabledPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_OUT_EN_PAYLOAD_CAMERA, this); + lp_var_t bootcause = lp_var_t(sid.objectId, P60System::PDU2_BOOTCAUSE, this); + /** Number of reboots */ + lp_var_t bootcount = lp_var_t(sid.objectId, P60System::PDU2_BOOTCNT, this); + /** Uptime in seconds */ + lp_var_t uptime = lp_var_t(sid.objectId, P60System::PDU2_UPTIME, this); + lp_var_t resetcause = + lp_var_t(sid.objectId, P60System::PDU2_RESETCAUSE, this); + /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ + lp_var_t battMode = lp_var_t(sid.objectId, P60System::PDU2_BATT_MODE, this); - lp_var_t bootcause = lp_var_t(sid.objectId, - P60System::PDU2_BOOTCAUSE, this); - /** Number of reboots */ - lp_var_t bootcount = lp_var_t(sid.objectId, - P60System::PDU2_BOOTCNT, this); - /** Uptime in seconds */ - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::PDU2_UPTIME, this); - lp_var_t resetcause = lp_var_t(sid.objectId, - P60System::PDU2_RESETCAUSE, this); - /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ - lp_var_t battMode = lp_var_t(sid.objectId, - P60System::PDU2_BATT_MODE, this); + /** Number of detected latchups on each output channel */ + lp_var_t latchupsQ7S = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_Q7S, this); + lp_var_t latchupsPayloadPcduCh1 = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, this); + lp_var_t latchupsRw = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_RW, this); + lp_var_t latchupsTcsBoardHeaterIn = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, this); + lp_var_t latchupsSusRedundant = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_SUS_REDUNDANT, this); + lp_var_t latchupsDeplMenchanism = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, this); + lp_var_t latchupsPayloadPcduCh6 = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, this); + lp_var_t latchupsAcsBoardSideB = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, this); + lp_var_t latchupsPayloadCamera = + lp_var_t(sid.objectId, P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, this); - /** Number of detected latchups on each output channel */ - lp_var_t latchupsQ7S = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_Q7S, this); - lp_var_t latchupsPayloadPcduCh1 = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH1, this); - lp_var_t latchupsRw = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_RW, this); - lp_var_t latchupsTcsBoardHeaterIn = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_TCS_BOARD_HEATER_IN, this); - lp_var_t latchupsSusRedundant = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_SUS_REDUNDANT, this); - lp_var_t latchupsDeplMenchanism = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_DEPLOYMENT_MECHANISM, this); - lp_var_t latchupsPayloadPcduCh6 = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_PCDU_CH6, this); - lp_var_t latchupsAcsBoardSideB = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_ACS_BOARD_SIDE_B, this); - lp_var_t latchupsPayloadCamera = lp_var_t(sid.objectId, - P60System::PDU2_LATCHUP_PAYLOAD_CAMERA, this); + /** + * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is + * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. + */ + lp_var_t device0 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::PDU2_DEVICE_7, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::PDU2_DEVICE_7_STATUS, this); - /** - * There are 8 devices on the PDU. FRAM, ADCs, temperature sensor etc. Each device is - * identified by an ID. Refer also to gs-man-nanopower-p60-pdu-200-1.pdf on pages 17 and 18. - */ - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_7, this); - /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::PDU2_DEVICE_7_STATUS, this); - - /** Number of reboots triggered by the ground watchdog */ - lp_var_t gndWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_GND, this); - /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ - lp_var_t i2cWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_I2C, this); - /** Number of reboots triggered through the CAN watchdog */ - lp_var_t canWdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CAN, this); - /** Number of reboots triggered through the CSP watchdog */ - lp_var_t csp1WdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CSP1, this); - lp_var_t csp2WdtReboots = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CNT_CSP2, this); - /** Ground watchdog remaining seconds before rebooting */ - lp_var_t groundWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_GND_LEFT, this); - /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ - lp_var_t i2cWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_I2C_LEFT, this); - /** CAN watchdog remaining seconds before rebooting. */ - lp_var_t canWatchdogSecondsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CAN_LEFT, this); - /** CSP watchdog remaining pings before rebooting. */ - lp_var_t csp1WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CSP_LEFT1, this); - lp_var_t csp2WatchdogPingsLeft = lp_var_t(sid.objectId, - P60System::PDU2_WDT_CSP_LEFT2, this); + /** Number of reboots triggered by the ground watchdog */ + lp_var_t gndWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_GND, this); + /** Number of reboots triggered through the I2C watchdog. Not relevant for EIVE. */ + lp_var_t i2cWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_I2C, this); + /** Number of reboots triggered through the CAN watchdog */ + lp_var_t canWdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CAN, this); + /** Number of reboots triggered through the CSP watchdog */ + lp_var_t csp1WdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CSP1, this); + lp_var_t csp2WdtReboots = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CNT_CSP2, this); + /** Ground watchdog remaining seconds before rebooting */ + lp_var_t groundWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_GND_LEFT, this); + /** I2C watchdog remaining seconds before rebooting. Not relevant for EIVE. */ + lp_var_t i2cWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_I2C_LEFT, this); + /** CAN watchdog remaining seconds before rebooting. */ + lp_var_t canWatchdogSecondsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CAN_LEFT, this); + /** CSP watchdog remaining pings before rebooting. */ + lp_var_t csp1WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CSP_LEFT1, this); + lp_var_t csp2WatchdogPingsLeft = + lp_var_t(sid.objectId, P60System::PDU2_WDT_CSP_LEFT2, this); }; -} - +} // namespace PDU2 namespace ACU { @@ -1060,157 +999,133 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 262; /** * @brief This class defines a dataset for the hk table of the ACU. */ -class HkTableDataset: - public StaticLocalDataSet { - public: +class HkTableDataset : public StaticLocalDataSet { + public: + HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} - HkTableDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) { - } + HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} - HkTableDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) { - } + lp_var_t currentInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL0, this); + lp_var_t currentInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL1, this); + lp_var_t currentInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL2, this); + lp_var_t currentInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL3, this); + lp_var_t currentInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL4, this); + lp_var_t currentInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_CURRENT_IN_CHANNEL5, this); - lp_var_t currentInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL0, this); - lp_var_t currentInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL1, this); - lp_var_t currentInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL2, this); - lp_var_t currentInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL3, this); - lp_var_t currentInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL4, this); - lp_var_t currentInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_CURRENT_IN_CHANNEL5, this); + lp_var_t voltageInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL0, this); + lp_var_t voltageInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL1, this); + lp_var_t voltageInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL2, this); + lp_var_t voltageInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL3, this); + lp_var_t voltageInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL4, this); + lp_var_t voltageInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_VOLTAGE_IN_CHANNEL5, this); - lp_var_t voltageInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL0, this); - lp_var_t voltageInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL1, this); - lp_var_t voltageInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL2, this); - lp_var_t voltageInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL3, this); - lp_var_t voltageInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL4, this); - lp_var_t voltageInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_VOLTAGE_IN_CHANNEL5, this); + lp_var_t vcc = lp_var_t(sid.objectId, P60System::ACU_VCC, this); + lp_var_t vbat = lp_var_t(sid.objectId, P60System::ACU_VBAT, this); - lp_var_t vcc = lp_var_t(sid.objectId, - P60System::ACU_VCC, this); - lp_var_t vbat = lp_var_t(sid.objectId, - P60System::ACU_VBAT, this); + lp_var_t temperature1 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_1, this); + lp_var_t temperature2 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_2, this); + lp_var_t temperature3 = + lp_var_t(sid.objectId, P60System::ACU_TEMPERATURE_3, this); - lp_var_t temperature1 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_1, this); - lp_var_t temperature2 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_2, this); - lp_var_t temperature3 = lp_var_t(sid.objectId, - P60System::ACU_TEMPERATURE_3, this); + lp_var_t mpptMode = lp_var_t(sid.objectId, P60System::ACU_MPPT_MODE, this); - lp_var_t mpptMode = lp_var_t(sid.objectId, - P60System::ACU_MPPT_MODE, this); + lp_var_t vboostInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL0, this); + lp_var_t vboostInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL1, this); + lp_var_t vboostInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL2, this); + lp_var_t vboostInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL3, this); + lp_var_t vboostInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL4, this); + lp_var_t vboostInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_VBOOST_CHANNEL5, this); - lp_var_t vboostInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL0, this); - lp_var_t vboostInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL1, this); - lp_var_t vboostInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL2, this); - lp_var_t vboostInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL3, this); - lp_var_t vboostInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL4, this); - lp_var_t vboostInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_VBOOST_CHANNEL5, this); + lp_var_t powerInChannel0 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL0, this); + lp_var_t powerInChannel1 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL1, this); + lp_var_t powerInChannel2 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL2, this); + lp_var_t powerInChannel3 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL3, this); + lp_var_t powerInChannel4 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL4, this); + lp_var_t powerInChannel5 = + lp_var_t(sid.objectId, P60System::ACU_POWER_CHANNEL5, this); - lp_var_t powerInChannel0 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL0, this); - lp_var_t powerInChannel1 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL1, this); - lp_var_t powerInChannel2 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL2, this); - lp_var_t powerInChannel3 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL3, this); - lp_var_t powerInChannel4 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL4, this); - lp_var_t powerInChannel5 = lp_var_t(sid.objectId, - P60System::ACU_POWER_CHANNEL5, this); + lp_var_t dac0Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_0, this); + lp_var_t dac1Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_1, this); + lp_var_t dac2Enable = lp_var_t(sid.objectId, P60System::ACU_DAC_EN_2, this); - lp_var_t dac0Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_0, this); - lp_var_t dac1Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_1, this); - lp_var_t dac2Enable = lp_var_t(sid.objectId, - P60System::ACU_DAC_EN_2, this); + lp_var_t dacRawChannelVal0 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_0, this); + lp_var_t dacRawChannelVal1 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_1, this); + lp_var_t dacRawChannelVal2 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_2, this); + lp_var_t dacRawChannelVal3 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_3, this); + lp_var_t dacRawChannelVal4 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_4, this); + lp_var_t dacRawChannelVal5 = + lp_var_t(sid.objectId, P60System::ACU_DAC_RAW_5, this); - lp_var_t dacRawChannelVal0 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_0, this); - lp_var_t dacRawChannelVal1 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_1, this); - lp_var_t dacRawChannelVal2 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_2, this); - lp_var_t dacRawChannelVal3 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_3, this); - lp_var_t dacRawChannelVal4 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_4, this); - lp_var_t dacRawChannelVal5 = lp_var_t(sid.objectId, - P60System::ACU_DAC_RAW_5, this); + lp_var_t bootCause = lp_var_t(sid.objectId, P60System::ACU_BOOTCAUSE, this); + lp_var_t bootcnt = lp_var_t(sid.objectId, P60System::ACU_BOOTCNT, this); + lp_var_t uptime = lp_var_t(sid.objectId, P60System::ACU_UPTIME, this); + lp_var_t resetCause = + lp_var_t(sid.objectId, P60System::ACU_RESET_CAUSE, this); + lp_var_t mpptTime = lp_var_t(sid.objectId, P60System::ACU_MPPT_TIME, this); + lp_var_t mpptPeriod = + lp_var_t(sid.objectId, P60System::ACU_MPPT_PERIOD, this); - lp_var_t bootCause = lp_var_t(sid.objectId, - P60System::ACU_BOOTCAUSE, this); - lp_var_t bootcnt = lp_var_t(sid.objectId, - P60System::ACU_BOOTCNT, this); - lp_var_t uptime = lp_var_t(sid.objectId, - P60System::ACU_UPTIME, this); - lp_var_t resetCause = lp_var_t(sid.objectId, - P60System::ACU_RESET_CAUSE, this); - lp_var_t mpptTime = lp_var_t(sid.objectId, - P60System::ACU_MPPT_TIME, this); - lp_var_t mpptPeriod = lp_var_t(sid.objectId, - P60System::ACU_MPPT_PERIOD, this); + lp_var_t device0 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_0, this); + lp_var_t device1 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_1, this); + lp_var_t device2 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_2, this); + lp_var_t device3 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_3, this); + lp_var_t device4 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_4, this); + lp_var_t device5 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_5, this); + lp_var_t device6 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_6, this); + lp_var_t device7 = lp_var_t(sid.objectId, P60System::ACU_DEVICE_7, this); - lp_var_t device0 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_7, this); + lp_var_t device0Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_0_STATUS, this); + lp_var_t device1Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_1_STATUS, this); + lp_var_t device2Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_2_STATUS, this); + lp_var_t device3Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_3_STATUS, this); + lp_var_t device4Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_4_STATUS, this); + lp_var_t device5Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_5_STATUS, this); + lp_var_t device6Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_6_STATUS, this); + lp_var_t device7Status = + lp_var_t(sid.objectId, P60System::ACU_DEVICE_7_STATUS, this); - lp_var_t device0Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_0_STATUS, this); - lp_var_t device1Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_1_STATUS, this); - lp_var_t device2Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_2_STATUS, this); - lp_var_t device3Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_3_STATUS, this); - lp_var_t device4Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_4_STATUS, this); - lp_var_t device5Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_5_STATUS, this); - lp_var_t device6Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_6_STATUS, this); - lp_var_t device7Status = lp_var_t(sid.objectId, - P60System::ACU_DEVICE_7_STATUS, this); - - lp_var_t wdtCntGnd = lp_var_t(sid.objectId, - P60System::ACU_WDT_CNT_GND, this); - lp_var_t wdtGndLeft = lp_var_t(sid.objectId, - P60System::ACU_WDT_GND_LEFT, this); + lp_var_t wdtCntGnd = lp_var_t(sid.objectId, P60System::ACU_WDT_CNT_GND, this); + lp_var_t wdtGndLeft = + lp_var_t(sid.objectId, P60System::ACU_WDT_GND_LEFT, this); }; -} +} // namespace ACU #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h index 62744e3a..a09d2fb7 100644 --- a/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h +++ b/mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h @@ -1,17 +1,14 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ -#include "fsfw/devicehandlers/DeviceHandlerIF.h" -#include "fsfw/datapoollocal/StaticLocalDataSet.h" - #include +#include "fsfw/datapoollocal/StaticLocalDataSet.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" + namespace ADIS1650X { -enum class Type { - ADIS16505, - ADIS16507 -}; +enum class Type { ADIS16505, ADIS16507 }; static constexpr size_t MAXIMUM_REPLY_SIZE = 64; static constexpr uint8_t WRITE_MASK = 0b1000'0000; @@ -63,91 +60,82 @@ static constexpr size_t SENSOR_READOUT_SIZE = 20 + 2; static constexpr uint32_t ADIS_DATASET_ID = READ_SENSOR_DATA; static constexpr uint32_t ADIS_CFG_DATASET_ID = READ_OUT_CONFIG; -enum GlobCmds: uint8_t { - FACTORY_CALIBRATION = 0b0000'0010, - SENSOR_SELF_TEST = 0b0000'0100, - FLASH_MEMORY_UPDATE = 0b0000'1000, - FLASH_MEMORY_TEST = 0b0001'0000, - SOFTWARE_RESET = 0b1000'0000 +enum GlobCmds : uint8_t { + FACTORY_CALIBRATION = 0b0000'0010, + SENSOR_SELF_TEST = 0b0000'0100, + FLASH_MEMORY_UPDATE = 0b0000'1000, + FLASH_MEMORY_TEST = 0b0001'0000, + SOFTWARE_RESET = 0b1000'0000 }; -enum PrimaryPoolIds: lp_id_t { - ANG_VELOC_X, - ANG_VELOC_Y, - ANG_VELOC_Z, - ACCELERATION_X, - ACCELERATION_Y, - ACCELERATION_Z, - TEMPERATURE, - DIAG_STAT_REGISTER, - FILTER_SETTINGS, - MSC_CTRL_REGISTER, - DEC_RATE_REGISTER, +enum PrimaryPoolIds : lp_id_t { + ANG_VELOC_X, + ANG_VELOC_Y, + ANG_VELOC_Z, + ACCELERATION_X, + ACCELERATION_Y, + ACCELERATION_Z, + TEMPERATURE, + DIAG_STAT_REGISTER, + FILTER_SETTINGS, + MSC_CTRL_REGISTER, + DEC_RATE_REGISTER, }; -enum FilterSettings: uint8_t { - NO_FILTER = 0, - TWO_TAPS = 1, - FOUR_TAPS = 2, - EIGHT_TAPS = 3, - SIXTEEN_TAPS = 4, - THIRTYTWO_TAPS = 5, - SIXTYFOUR_TAPS = 6 +enum FilterSettings : uint8_t { + NO_FILTER = 0, + TWO_TAPS = 1, + FOUR_TAPS = 2, + EIGHT_TAPS = 3, + SIXTEEN_TAPS = 4, + THIRTYTWO_TAPS = 5, + SIXTYFOUR_TAPS = 6 }; -} +} // namespace ADIS1650X -class AdisGyroPrimaryDataset: public StaticLocalDataSet<8> { -public: +class AdisGyroPrimaryDataset : public StaticLocalDataSet<8> { + public: + /** Constructor for data users like controllers */ + AdisGyroPrimaryDataset(object_id_t adisId) + : StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) { + setAllVariablesReadOnly(); + } - /** Constructor for data users like controllers */ - AdisGyroPrimaryDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_DATASET_ID)) { - setAllVariablesReadOnly(); - } + /* Angular velocities in degrees per second (DPS) */ + lp_var_t angVelocX = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_X, this); + lp_var_t angVelocY = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_Y, this); + lp_var_t angVelocZ = lp_var_t(sid.objectId, ADIS1650X::ANG_VELOC_Z, this); + lp_var_t accelX = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_X, this); + lp_var_t accelY = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_Y, this); + lp_var_t accelZ = lp_var_t(sid.objectId, ADIS1650X::ACCELERATION_Z, this); + lp_var_t temperature = lp_var_t(sid.objectId, ADIS1650X::TEMPERATURE, this); - /* Angular velocities in degrees per second (DPS) */ - lp_var_t angVelocX = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_X, this); - lp_var_t angVelocY = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_Y, this); - lp_var_t angVelocZ = lp_var_t(sid.objectId, - ADIS1650X::ANG_VELOC_Z, this); - lp_var_t accelX = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_X, this); - lp_var_t accelY = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_Y, this); - lp_var_t accelZ = lp_var_t(sid.objectId, - ADIS1650X::ACCELERATION_Z, this); - lp_var_t temperature = lp_var_t(sid.objectId, - ADIS1650X::TEMPERATURE, this); -private: - - friend class GyroADIS1650XHandler; - /** Constructor for the data creator */ - AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {} + private: + friend class GyroADIS1650XHandler; + /** Constructor for the data creator */ + AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_DATASET_ID) {} }; -class AdisGyroConfigDataset: public StaticLocalDataSet<5> { -public: +class AdisGyroConfigDataset : public StaticLocalDataSet<5> { + public: + /** Constructor for data users like controllers */ + AdisGyroConfigDataset(object_id_t adisId) + : StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) { + setAllVariablesReadOnly(); + } - /** Constructor for data users like controllers */ - AdisGyroConfigDataset(object_id_t adisId): - StaticLocalDataSet(sid_t(adisId, ADIS1650X::ADIS_CFG_DATASET_ID)) { - setAllVariablesReadOnly(); - } + lp_var_t diagStatReg = lp_var_t(sid.objectId, ADIS1650X::DIAG_STAT_REGISTER); + lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS1650X::FILTER_SETTINGS); + lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER); + lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS1650X::DEC_RATE_REGISTER); - lp_var_t diagStatReg = lp_var_t(sid.objectId, - ADIS1650X::DIAG_STAT_REGISTER); - lp_var_t filterSetting = lp_var_t(sid.objectId, ADIS1650X::FILTER_SETTINGS); - lp_var_t mscCtrlReg = lp_var_t(sid.objectId, ADIS1650X::MSC_CTRL_REGISTER); - lp_var_t decRateReg = lp_var_t(sid.objectId, ADIS1650X::DEC_RATE_REGISTER); -private: - friend class GyroADIS1650XHandler; - /** Constructor for the data creator */ - AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {} + private: + friend class GyroADIS1650XHandler; + /** Constructor for the data creator */ + AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, ADIS1650X::ADIS_CFG_DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/GyroL3GD20Definitions.h b/mission/devices/devicedefinitions/GyroL3GD20Definitions.h index b5b80495..4c4543d0 100644 --- a/mission/devices/devicedefinitions/GyroL3GD20Definitions.h +++ b/mission/devices/devicedefinitions/GyroL3GD20Definitions.h @@ -3,6 +3,7 @@ #include #include + #include namespace L3GD20H { @@ -36,8 +37,8 @@ static constexpr uint8_t SET_Z_ENABLE = 1 << 2; static constexpr uint8_t SET_X_ENABLE = 1 << 1; static constexpr uint8_t SET_Y_ENABLE = 1; -static constexpr uint8_t CTRL_REG_1_VAL = SET_POWER_NORMAL_MODE | SET_Z_ENABLE | - SET_Y_ENABLE | SET_X_ENABLE; +static constexpr uint8_t CTRL_REG_1_VAL = + SET_POWER_NORMAL_MODE | SET_Z_ENABLE | SET_Y_ENABLE | SET_X_ENABLE; /* Register 2 */ static constexpr uint8_t EXTERNAL_EDGE_ENB = 1 << 7; @@ -101,40 +102,29 @@ static constexpr DeviceCommandId_t READ_CTRL_REGS = 2; static constexpr uint32_t GYRO_DATASET_ID = READ_REGS; -enum GyroPoolIds: lp_id_t { - ANG_VELOC_X, - ANG_VELOC_Y, - ANG_VELOC_Z, - TEMPERATURE +enum GyroPoolIds : lp_id_t { ANG_VELOC_X, ANG_VELOC_Y, ANG_VELOC_Z, TEMPERATURE }; + +} // namespace L3GD20H + +class GyroPrimaryDataset : public StaticLocalDataSet<5> { + public: + /** Constructor for data users like controllers */ + GyroPrimaryDataset(object_id_t mgmId) + : StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) { + setAllVariablesReadOnly(); + } + + /* Angular velocities in degrees per second (DPS) */ + lp_var_t angVelocX = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_X, this); + lp_var_t angVelocY = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_Y, this); + lp_var_t angVelocZ = lp_var_t(sid.objectId, L3GD20H::ANG_VELOC_Z, this); + lp_var_t temperature = lp_var_t(sid.objectId, L3GD20H::TEMPERATURE, this); + + private: + friend class GyroHandlerL3GD20H; + /** Constructor for the data creator */ + GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {} }; -} - -class GyroPrimaryDataset: public StaticLocalDataSet<5> { -public: - - /** Constructor for data users like controllers */ - GyroPrimaryDataset(object_id_t mgmId): - StaticLocalDataSet(sid_t(mgmId, L3GD20H::GYRO_DATASET_ID)) { - setAllVariablesReadOnly(); - } - - /* Angular velocities in degrees per second (DPS) */ - lp_var_t angVelocX = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_X, this); - lp_var_t angVelocY = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_Y, this); - lp_var_t angVelocZ = lp_var_t(sid.objectId, - L3GD20H::ANG_VELOC_Z, this); - lp_var_t temperature = lp_var_t(sid.objectId, - L3GD20H::TEMPERATURE, this); -private: - - friend class GyroHandlerL3GD20H; - /** Constructor for the data creator */ - GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, L3GD20H::GYRO_DATASET_ID) {} -}; - - #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROL3GD20DEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h b/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h index e95bd42e..609bbdf8 100644 --- a/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h +++ b/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h @@ -5,453 +5,435 @@ namespace IMTQ { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t GET_ENG_HK_DATA = 0x1; - static const DeviceCommandId_t START_ACTUATION_DIPOLE = 0x2; - static const DeviceCommandId_t GET_COMMANDED_DIPOLE = 0x3; - /** Generates new measurement of the magnetic field */ - static const DeviceCommandId_t START_MTM_MEASUREMENT = 0x4; - /** Requests the calibrated magnetometer measurement */ - static const DeviceCommandId_t GET_CAL_MTM_MEASUREMENT = 0x5; - /** Requests the raw values measured by the built-in MTM XEN1210 */ - static const DeviceCommandId_t GET_RAW_MTM_MEASUREMENT = 0x6; - static const DeviceCommandId_t POS_X_SELF_TEST = 0x7; - static const DeviceCommandId_t NEG_X_SELF_TEST = 0x8; - static const DeviceCommandId_t POS_Y_SELF_TEST = 0x9; - static const DeviceCommandId_t NEG_Y_SELF_TEST = 0xA; - static const DeviceCommandId_t POS_Z_SELF_TEST = 0xB; - static const DeviceCommandId_t NEG_Z_SELF_TEST = 0xC; - static const DeviceCommandId_t GET_SELF_TEST_RESULT = 0xD; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t GET_ENG_HK_DATA = 0x1; +static const DeviceCommandId_t START_ACTUATION_DIPOLE = 0x2; +static const DeviceCommandId_t GET_COMMANDED_DIPOLE = 0x3; +/** Generates new measurement of the magnetic field */ +static const DeviceCommandId_t START_MTM_MEASUREMENT = 0x4; +/** Requests the calibrated magnetometer measurement */ +static const DeviceCommandId_t GET_CAL_MTM_MEASUREMENT = 0x5; +/** Requests the raw values measured by the built-in MTM XEN1210 */ +static const DeviceCommandId_t GET_RAW_MTM_MEASUREMENT = 0x6; +static const DeviceCommandId_t POS_X_SELF_TEST = 0x7; +static const DeviceCommandId_t NEG_X_SELF_TEST = 0x8; +static const DeviceCommandId_t POS_Y_SELF_TEST = 0x9; +static const DeviceCommandId_t NEG_Y_SELF_TEST = 0xA; +static const DeviceCommandId_t POS_Z_SELF_TEST = 0xB; +static const DeviceCommandId_t NEG_Z_SELF_TEST = 0xC; +static const DeviceCommandId_t GET_SELF_TEST_RESULT = 0xD; - static const uint8_t GET_TEMP_REPLY_SIZE = 2; - static const uint8_t CFGR_CMD_SIZE = 3; - static const uint8_t POINTER_REG_SIZE = 1; +static const uint8_t GET_TEMP_REPLY_SIZE = 2; +static const uint8_t CFGR_CMD_SIZE = 3; +static const uint8_t POINTER_REG_SIZE = 1; - static const uint32_t ENG_HK_DATA_SET_ID = 1; - static const uint32_t CAL_MTM_SET = 2; - static const uint32_t RAW_MTM_SET = 3; - static const uint32_t POS_X_TEST_DATASET = 4; - static const uint32_t NEG_X_TEST_DATASET = 5; - static const uint32_t POS_Y_TEST_DATASET = 6; - static const uint32_t NEG_Y_TEST_DATASET = 7; - static const uint32_t POS_Z_TEST_DATASET = 8; - static const uint32_t NEG_Z_TEST_DATASET = 9; +static const uint32_t ENG_HK_DATA_SET_ID = 1; +static const uint32_t CAL_MTM_SET = 2; +static const uint32_t RAW_MTM_SET = 3; +static const uint32_t POS_X_TEST_DATASET = 4; +static const uint32_t NEG_X_TEST_DATASET = 5; +static const uint32_t POS_Y_TEST_DATASET = 6; +static const uint32_t NEG_Y_TEST_DATASET = 7; +static const uint32_t POS_Z_TEST_DATASET = 8; +static const uint32_t NEG_Z_TEST_DATASET = 9; - static const uint8_t SIZE_ENG_HK_COMMAND = 1; - static const uint8_t SIZE_STATUS_REPLY = 2; - static const uint8_t SIZE_ENG_HK_DATA_REPLY = 24; - static const uint8_t SIZE_GET_COMMANDED_DIPOLE_REPLY = 8; - static const uint8_t SIZE_GET_CAL_MTM_MEASUREMENT = 15; - static const uint8_t SIZE_GET_RAW_MTM_MEASUREMENT = 15; - static const uint16_t SIZE_SELF_TEST_RESULTS = 120; +static const uint8_t SIZE_ENG_HK_COMMAND = 1; +static const uint8_t SIZE_STATUS_REPLY = 2; +static const uint8_t SIZE_ENG_HK_DATA_REPLY = 24; +static const uint8_t SIZE_GET_COMMANDED_DIPOLE_REPLY = 8; +static const uint8_t SIZE_GET_CAL_MTM_MEASUREMENT = 15; +static const uint8_t SIZE_GET_RAW_MTM_MEASUREMENT = 15; +static const uint16_t SIZE_SELF_TEST_RESULTS = 120; - static const uint16_t MAX_REPLY_SIZE = SIZE_SELF_TEST_RESULTS; - static const uint8_t MAX_COMMAND_SIZE = 9; +static const uint16_t MAX_REPLY_SIZE = SIZE_SELF_TEST_RESULTS; +static const uint8_t MAX_COMMAND_SIZE = 9; - /** Define entries in IMTQ specific dataset */ - static const uint8_t ENG_HK_SET_POOL_ENTRIES = 11; - static const uint8_t CAL_MTM_POOL_ENTRIES = 4; - static const uint8_t SELF_TEST_DATASET_ENTRIES = 104; +/** Define entries in IMTQ specific dataset */ +static const uint8_t ENG_HK_SET_POOL_ENTRIES = 11; +static const uint8_t CAL_MTM_POOL_ENTRIES = 4; +static const uint8_t SELF_TEST_DATASET_ENTRIES = 104; - /** Error codes for interpreting the self test error byte */ - static const uint8_t I2C_FAILURE_MASK = 0x1; - static const uint8_t SPI_FAILURE_MASK = 0x2; // MTM connectivity - static const uint8_t ADC_FAILURE_MASK = 0x4; // Current/Temp measurement - static const uint8_t PWM_FAILURE_MASK = 0x8; // Coil actuation - static const uint8_t TC_FAILURE_MASK = 0x10; // System failure - static const uint8_t MTM_RANGE_FAILURE_MASK = 0x20; // MTM values outside of expected range - static const uint8_t COIL_CURRENT_FAILURE_MASK = 0x40; // Coil currents outside of expected range - static const uint8_t INVALID_ERROR_BYTE = 0x80; // This is an invalid error byte and should be never replied by the IMTQ +/** Error codes for interpreting the self test error byte */ +static const uint8_t I2C_FAILURE_MASK = 0x1; +static const uint8_t SPI_FAILURE_MASK = 0x2; // MTM connectivity +static const uint8_t ADC_FAILURE_MASK = 0x4; // Current/Temp measurement +static const uint8_t PWM_FAILURE_MASK = 0x8; // Coil actuation +static const uint8_t TC_FAILURE_MASK = 0x10; // System failure +static const uint8_t MTM_RANGE_FAILURE_MASK = 0x20; // MTM values outside of expected range +static const uint8_t COIL_CURRENT_FAILURE_MASK = 0x40; // Coil currents outside of expected range +static const uint8_t INVALID_ERROR_BYTE = + 0x80; // This is an invalid error byte and should be never replied by the IMTQ - static const uint8_t MAIN_STEP_OFFSET = 43; +static const uint8_t MAIN_STEP_OFFSET = 43; - /** - * Command code definitions. Each command or reply of an IMTQ request will begin with one of - * the following command codes. - */ - namespace CC { - static const uint8_t START_MTM_MEASUREMENT = 0x4; - static const uint8_t START_ACTUATION_DIPOLE = 0x6; - static const uint8_t SELF_TEST_CMD = 0x8; - static const uint8_t SOFTWARE_RESET = 0xAA; - static const uint8_t GET_ENG_HK_DATA = 0x4A; - static const uint8_t GET_COMMANDED_DIPOLE = 0x46; - static const uint8_t GET_RAW_MTM_MEASUREMENT = 0x42; - static const uint8_t GET_CAL_MTM_MEASUREMENT = 0x43; - static const uint8_t GET_SELF_TEST_RESULT = 0x47; - }; +/** + * Command code definitions. Each command or reply of an IMTQ request will begin with one of + * the following command codes. + */ +namespace CC { +static const uint8_t START_MTM_MEASUREMENT = 0x4; +static const uint8_t START_ACTUATION_DIPOLE = 0x6; +static const uint8_t SELF_TEST_CMD = 0x8; +static const uint8_t SOFTWARE_RESET = 0xAA; +static const uint8_t GET_ENG_HK_DATA = 0x4A; +static const uint8_t GET_COMMANDED_DIPOLE = 0x46; +static const uint8_t GET_RAW_MTM_MEASUREMENT = 0x42; +static const uint8_t GET_CAL_MTM_MEASUREMENT = 0x43; +static const uint8_t GET_SELF_TEST_RESULT = 0x47; +}; // namespace CC - namespace SELF_TEST_AXIS { - static const uint8_t ALL = 0x0; - static const uint8_t X_POSITIVE = 0x1; - static const uint8_t X_NEGATIVE = 0x2; - static const uint8_t Y_POSITIVE = 0x3; - static const uint8_t Y_NEGATIVE = 0x4; - static const uint8_t Z_POSITIVE = 0x5; - static const uint8_t Z_NEGATIVE = 0x6; - } +namespace SELF_TEST_AXIS { +static const uint8_t ALL = 0x0; +static const uint8_t X_POSITIVE = 0x1; +static const uint8_t X_NEGATIVE = 0x2; +static const uint8_t Y_POSITIVE = 0x3; +static const uint8_t Y_NEGATIVE = 0x4; +static const uint8_t Z_POSITIVE = 0x5; +static const uint8_t Z_NEGATIVE = 0x6; +} // namespace SELF_TEST_AXIS - namespace SELF_TEST_STEPS { - static const uint8_t INIT = 0x0; - static const uint8_t X_POSITIVE = 0x1; - static const uint8_t X_NEGATIVE = 0x2; - static const uint8_t Y_POSITIVE = 0x3; - static const uint8_t Y_NEGATIVE = 0x4; - static const uint8_t Z_POSITIVE = 0x5; - static const uint8_t Z_NEGATIVE = 0x6; - static const uint8_t FINA = 0x7; - } +namespace SELF_TEST_STEPS { +static const uint8_t INIT = 0x0; +static const uint8_t X_POSITIVE = 0x1; +static const uint8_t X_NEGATIVE = 0x2; +static const uint8_t Y_POSITIVE = 0x3; +static const uint8_t Y_NEGATIVE = 0x4; +static const uint8_t Z_POSITIVE = 0x5; +static const uint8_t Z_NEGATIVE = 0x6; +static const uint8_t FINA = 0x7; +} // namespace SELF_TEST_STEPS - enum IMTQPoolIds: lp_id_t { - DIGITAL_VOLTAGE_MV, - ANALOG_VOLTAGE_MV, - DIGITAL_CURRENT, - ANALOG_CURRENT, - COIL_X_CURRENT, - COIL_Y_CURRENT, - COIL_Z_CURRENT, - COIL_X_TEMPERATURE, - COIL_Y_TEMPERATURE, - COIL_Z_TEMPERATURE, - MCU_TEMPERATURE, - MTM_CAL_X, - MTM_CAL_Y, - MTM_CAL_Z, - ACTUATION_CAL_STATUS, - MTM_RAW_X, - MTM_RAW_Y, - MTM_RAW_Z, - ACTUATION_RAW_STATUS, +enum IMTQPoolIds : lp_id_t { + DIGITAL_VOLTAGE_MV, + ANALOG_VOLTAGE_MV, + DIGITAL_CURRENT, + ANALOG_CURRENT, + COIL_X_CURRENT, + COIL_Y_CURRENT, + COIL_Z_CURRENT, + COIL_X_TEMPERATURE, + COIL_Y_TEMPERATURE, + COIL_Z_TEMPERATURE, + MCU_TEMPERATURE, + MTM_CAL_X, + MTM_CAL_Y, + MTM_CAL_Z, + ACTUATION_CAL_STATUS, + MTM_RAW_X, + MTM_RAW_Y, + MTM_RAW_Z, + ACTUATION_RAW_STATUS, - INIT_POS_X_ERR, - INIT_POS_X_RAW_MAG_X, - INIT_POS_X_RAW_MAG_Y, - INIT_POS_X_RAW_MAG_Z, - INIT_POS_X_CAL_MAG_X, - INIT_POS_X_CAL_MAG_Y, - INIT_POS_X_CAL_MAG_Z, - INIT_POS_X_COIL_X_CURRENT, - INIT_POS_X_COIL_Y_CURRENT, - INIT_POS_X_COIL_Z_CURRENT, - INIT_POS_X_COIL_X_TEMPERATURE, - INIT_POS_X_COIL_Y_TEMPERATURE, - INIT_POS_X_COIL_Z_TEMPERATURE, + INIT_POS_X_ERR, + INIT_POS_X_RAW_MAG_X, + INIT_POS_X_RAW_MAG_Y, + INIT_POS_X_RAW_MAG_Z, + INIT_POS_X_CAL_MAG_X, + INIT_POS_X_CAL_MAG_Y, + INIT_POS_X_CAL_MAG_Z, + INIT_POS_X_COIL_X_CURRENT, + INIT_POS_X_COIL_Y_CURRENT, + INIT_POS_X_COIL_Z_CURRENT, + INIT_POS_X_COIL_X_TEMPERATURE, + INIT_POS_X_COIL_Y_TEMPERATURE, + INIT_POS_X_COIL_Z_TEMPERATURE, - INIT_NEG_X_ERR, - INIT_NEG_X_RAW_MAG_X, - INIT_NEG_X_RAW_MAG_Y, - INIT_NEG_X_RAW_MAG_Z, - INIT_NEG_X_CAL_MAG_X, - INIT_NEG_X_CAL_MAG_Y, - INIT_NEG_X_CAL_MAG_Z, - INIT_NEG_X_COIL_X_CURRENT, - INIT_NEG_X_COIL_Y_CURRENT, - INIT_NEG_X_COIL_Z_CURRENT, - INIT_NEG_X_COIL_X_TEMPERATURE, - INIT_NEG_X_COIL_Y_TEMPERATURE, - INIT_NEG_X_COIL_Z_TEMPERATURE, + INIT_NEG_X_ERR, + INIT_NEG_X_RAW_MAG_X, + INIT_NEG_X_RAW_MAG_Y, + INIT_NEG_X_RAW_MAG_Z, + INIT_NEG_X_CAL_MAG_X, + INIT_NEG_X_CAL_MAG_Y, + INIT_NEG_X_CAL_MAG_Z, + INIT_NEG_X_COIL_X_CURRENT, + INIT_NEG_X_COIL_Y_CURRENT, + INIT_NEG_X_COIL_Z_CURRENT, + INIT_NEG_X_COIL_X_TEMPERATURE, + INIT_NEG_X_COIL_Y_TEMPERATURE, + INIT_NEG_X_COIL_Z_TEMPERATURE, - INIT_POS_Y_ERR, - INIT_POS_Y_RAW_MAG_X, - INIT_POS_Y_RAW_MAG_Y, - INIT_POS_Y_RAW_MAG_Z, - INIT_POS_Y_CAL_MAG_X, - INIT_POS_Y_CAL_MAG_Y, - INIT_POS_Y_CAL_MAG_Z, - INIT_POS_Y_COIL_X_CURRENT, - INIT_POS_Y_COIL_Y_CURRENT, - INIT_POS_Y_COIL_Z_CURRENT, - INIT_POS_Y_COIL_X_TEMPERATURE, - INIT_POS_Y_COIL_Y_TEMPERATURE, - INIT_POS_Y_COIL_Z_TEMPERATURE, + INIT_POS_Y_ERR, + INIT_POS_Y_RAW_MAG_X, + INIT_POS_Y_RAW_MAG_Y, + INIT_POS_Y_RAW_MAG_Z, + INIT_POS_Y_CAL_MAG_X, + INIT_POS_Y_CAL_MAG_Y, + INIT_POS_Y_CAL_MAG_Z, + INIT_POS_Y_COIL_X_CURRENT, + INIT_POS_Y_COIL_Y_CURRENT, + INIT_POS_Y_COIL_Z_CURRENT, + INIT_POS_Y_COIL_X_TEMPERATURE, + INIT_POS_Y_COIL_Y_TEMPERATURE, + INIT_POS_Y_COIL_Z_TEMPERATURE, - INIT_NEG_Y_ERR, - INIT_NEG_Y_RAW_MAG_X, - INIT_NEG_Y_RAW_MAG_Y, - INIT_NEG_Y_RAW_MAG_Z, - INIT_NEG_Y_CAL_MAG_X, - INIT_NEG_Y_CAL_MAG_Y, - INIT_NEG_Y_CAL_MAG_Z, - INIT_NEG_Y_COIL_X_CURRENT, - INIT_NEG_Y_COIL_Y_CURRENT, - INIT_NEG_Y_COIL_Z_CURRENT, - INIT_NEG_Y_COIL_X_TEMPERATURE, - INIT_NEG_Y_COIL_Y_TEMPERATURE, - INIT_NEG_Y_COIL_Z_TEMPERATURE, + INIT_NEG_Y_ERR, + INIT_NEG_Y_RAW_MAG_X, + INIT_NEG_Y_RAW_MAG_Y, + INIT_NEG_Y_RAW_MAG_Z, + INIT_NEG_Y_CAL_MAG_X, + INIT_NEG_Y_CAL_MAG_Y, + INIT_NEG_Y_CAL_MAG_Z, + INIT_NEG_Y_COIL_X_CURRENT, + INIT_NEG_Y_COIL_Y_CURRENT, + INIT_NEG_Y_COIL_Z_CURRENT, + INIT_NEG_Y_COIL_X_TEMPERATURE, + INIT_NEG_Y_COIL_Y_TEMPERATURE, + INIT_NEG_Y_COIL_Z_TEMPERATURE, - INIT_POS_Z_ERR, - INIT_POS_Z_RAW_MAG_X, - INIT_POS_Z_RAW_MAG_Y, - INIT_POS_Z_RAW_MAG_Z, - INIT_POS_Z_CAL_MAG_X, - INIT_POS_Z_CAL_MAG_Y, - INIT_POS_Z_CAL_MAG_Z, - INIT_POS_Z_COIL_X_CURRENT, - INIT_POS_Z_COIL_Y_CURRENT, - INIT_POS_Z_COIL_Z_CURRENT, - INIT_POS_Z_COIL_X_TEMPERATURE, - INIT_POS_Z_COIL_Y_TEMPERATURE, - INIT_POS_Z_COIL_Z_TEMPERATURE, + INIT_POS_Z_ERR, + INIT_POS_Z_RAW_MAG_X, + INIT_POS_Z_RAW_MAG_Y, + INIT_POS_Z_RAW_MAG_Z, + INIT_POS_Z_CAL_MAG_X, + INIT_POS_Z_CAL_MAG_Y, + INIT_POS_Z_CAL_MAG_Z, + INIT_POS_Z_COIL_X_CURRENT, + INIT_POS_Z_COIL_Y_CURRENT, + INIT_POS_Z_COIL_Z_CURRENT, + INIT_POS_Z_COIL_X_TEMPERATURE, + INIT_POS_Z_COIL_Y_TEMPERATURE, + INIT_POS_Z_COIL_Z_TEMPERATURE, - INIT_NEG_Z_ERR, - INIT_NEG_Z_RAW_MAG_X, - INIT_NEG_Z_RAW_MAG_Y, - INIT_NEG_Z_RAW_MAG_Z, - INIT_NEG_Z_CAL_MAG_X, - INIT_NEG_Z_CAL_MAG_Y, - INIT_NEG_Z_CAL_MAG_Z, - INIT_NEG_Z_COIL_X_CURRENT, - INIT_NEG_Z_COIL_Y_CURRENT, - INIT_NEG_Z_COIL_Z_CURRENT, - INIT_NEG_Z_COIL_X_TEMPERATURE, - INIT_NEG_Z_COIL_Y_TEMPERATURE, - INIT_NEG_Z_COIL_Z_TEMPERATURE, + INIT_NEG_Z_ERR, + INIT_NEG_Z_RAW_MAG_X, + INIT_NEG_Z_RAW_MAG_Y, + INIT_NEG_Z_RAW_MAG_Z, + INIT_NEG_Z_CAL_MAG_X, + INIT_NEG_Z_CAL_MAG_Y, + INIT_NEG_Z_CAL_MAG_Z, + INIT_NEG_Z_COIL_X_CURRENT, + INIT_NEG_Z_COIL_Y_CURRENT, + INIT_NEG_Z_COIL_Z_CURRENT, + INIT_NEG_Z_COIL_X_TEMPERATURE, + INIT_NEG_Z_COIL_Y_TEMPERATURE, + INIT_NEG_Z_COIL_Z_TEMPERATURE, - POS_X_ERR, - POS_X_RAW_MAG_X, - POS_X_RAW_MAG_Y, - POS_X_RAW_MAG_Z, - POS_X_CAL_MAG_X, - POS_X_CAL_MAG_Y, - POS_X_CAL_MAG_Z, - POS_X_COIL_X_CURRENT, - POS_X_COIL_Y_CURRENT, - POS_X_COIL_Z_CURRENT, - POS_X_COIL_X_TEMPERATURE, - POS_X_COIL_Y_TEMPERATURE, - POS_X_COIL_Z_TEMPERATURE, + POS_X_ERR, + POS_X_RAW_MAG_X, + POS_X_RAW_MAG_Y, + POS_X_RAW_MAG_Z, + POS_X_CAL_MAG_X, + POS_X_CAL_MAG_Y, + POS_X_CAL_MAG_Z, + POS_X_COIL_X_CURRENT, + POS_X_COIL_Y_CURRENT, + POS_X_COIL_Z_CURRENT, + POS_X_COIL_X_TEMPERATURE, + POS_X_COIL_Y_TEMPERATURE, + POS_X_COIL_Z_TEMPERATURE, - NEG_X_ERR, - NEG_X_RAW_MAG_X, - NEG_X_RAW_MAG_Y, - NEG_X_RAW_MAG_Z, - NEG_X_CAL_MAG_X, - NEG_X_CAL_MAG_Y, - NEG_X_CAL_MAG_Z, - NEG_X_COIL_X_CURRENT, - NEG_X_COIL_Y_CURRENT, - NEG_X_COIL_Z_CURRENT, - NEG_X_COIL_X_TEMPERATURE, - NEG_X_COIL_Y_TEMPERATURE, - NEG_X_COIL_Z_TEMPERATURE, + NEG_X_ERR, + NEG_X_RAW_MAG_X, + NEG_X_RAW_MAG_Y, + NEG_X_RAW_MAG_Z, + NEG_X_CAL_MAG_X, + NEG_X_CAL_MAG_Y, + NEG_X_CAL_MAG_Z, + NEG_X_COIL_X_CURRENT, + NEG_X_COIL_Y_CURRENT, + NEG_X_COIL_Z_CURRENT, + NEG_X_COIL_X_TEMPERATURE, + NEG_X_COIL_Y_TEMPERATURE, + NEG_X_COIL_Z_TEMPERATURE, - POS_Y_ERR, - POS_Y_RAW_MAG_X, - POS_Y_RAW_MAG_Y, - POS_Y_RAW_MAG_Z, - POS_Y_CAL_MAG_X, - POS_Y_CAL_MAG_Y, - POS_Y_CAL_MAG_Z, - POS_Y_COIL_X_CURRENT, - POS_Y_COIL_Y_CURRENT, - POS_Y_COIL_Z_CURRENT, - POS_Y_COIL_X_TEMPERATURE, - POS_Y_COIL_Y_TEMPERATURE, - POS_Y_COIL_Z_TEMPERATURE, + POS_Y_ERR, + POS_Y_RAW_MAG_X, + POS_Y_RAW_MAG_Y, + POS_Y_RAW_MAG_Z, + POS_Y_CAL_MAG_X, + POS_Y_CAL_MAG_Y, + POS_Y_CAL_MAG_Z, + POS_Y_COIL_X_CURRENT, + POS_Y_COIL_Y_CURRENT, + POS_Y_COIL_Z_CURRENT, + POS_Y_COIL_X_TEMPERATURE, + POS_Y_COIL_Y_TEMPERATURE, + POS_Y_COIL_Z_TEMPERATURE, - NEG_Y_ERR, - NEG_Y_RAW_MAG_X, - NEG_Y_RAW_MAG_Y, - NEG_Y_RAW_MAG_Z, - NEG_Y_CAL_MAG_X, - NEG_Y_CAL_MAG_Y, - NEG_Y_CAL_MAG_Z, - NEG_Y_COIL_X_CURRENT, - NEG_Y_COIL_Y_CURRENT, - NEG_Y_COIL_Z_CURRENT, - NEG_Y_COIL_X_TEMPERATURE, - NEG_Y_COIL_Y_TEMPERATURE, - NEG_Y_COIL_Z_TEMPERATURE, + NEG_Y_ERR, + NEG_Y_RAW_MAG_X, + NEG_Y_RAW_MAG_Y, + NEG_Y_RAW_MAG_Z, + NEG_Y_CAL_MAG_X, + NEG_Y_CAL_MAG_Y, + NEG_Y_CAL_MAG_Z, + NEG_Y_COIL_X_CURRENT, + NEG_Y_COIL_Y_CURRENT, + NEG_Y_COIL_Z_CURRENT, + NEG_Y_COIL_X_TEMPERATURE, + NEG_Y_COIL_Y_TEMPERATURE, + NEG_Y_COIL_Z_TEMPERATURE, - POS_Z_ERR, - POS_Z_RAW_MAG_X, - POS_Z_RAW_MAG_Y, - POS_Z_RAW_MAG_Z, - POS_Z_CAL_MAG_X, - POS_Z_CAL_MAG_Y, - POS_Z_CAL_MAG_Z, - POS_Z_COIL_X_CURRENT, - POS_Z_COIL_Y_CURRENT, - POS_Z_COIL_Z_CURRENT, - POS_Z_COIL_X_TEMPERATURE, - POS_Z_COIL_Y_TEMPERATURE, - POS_Z_COIL_Z_TEMPERATURE, + POS_Z_ERR, + POS_Z_RAW_MAG_X, + POS_Z_RAW_MAG_Y, + POS_Z_RAW_MAG_Z, + POS_Z_CAL_MAG_X, + POS_Z_CAL_MAG_Y, + POS_Z_CAL_MAG_Z, + POS_Z_COIL_X_CURRENT, + POS_Z_COIL_Y_CURRENT, + POS_Z_COIL_Z_CURRENT, + POS_Z_COIL_X_TEMPERATURE, + POS_Z_COIL_Y_TEMPERATURE, + POS_Z_COIL_Z_TEMPERATURE, - NEG_Z_ERR, - NEG_Z_RAW_MAG_X, - NEG_Z_RAW_MAG_Y, - NEG_Z_RAW_MAG_Z, - NEG_Z_CAL_MAG_X, - NEG_Z_CAL_MAG_Y, - NEG_Z_CAL_MAG_Z, - NEG_Z_COIL_X_CURRENT, - NEG_Z_COIL_Y_CURRENT, - NEG_Z_COIL_Z_CURRENT, - NEG_Z_COIL_X_TEMPERATURE, - NEG_Z_COIL_Y_TEMPERATURE, - NEG_Z_COIL_Z_TEMPERATURE, + NEG_Z_ERR, + NEG_Z_RAW_MAG_X, + NEG_Z_RAW_MAG_Y, + NEG_Z_RAW_MAG_Z, + NEG_Z_CAL_MAG_X, + NEG_Z_CAL_MAG_Y, + NEG_Z_CAL_MAG_Z, + NEG_Z_COIL_X_CURRENT, + NEG_Z_COIL_Y_CURRENT, + NEG_Z_COIL_Z_CURRENT, + NEG_Z_COIL_X_TEMPERATURE, + NEG_Z_COIL_Y_TEMPERATURE, + NEG_Z_COIL_Z_TEMPERATURE, - FINA_POS_X_ERR, - FINA_POS_X_RAW_MAG_X, - FINA_POS_X_RAW_MAG_Y, - FINA_POS_X_RAW_MAG_Z, - FINA_POS_X_CAL_MAG_X, - FINA_POS_X_CAL_MAG_Y, - FINA_POS_X_CAL_MAG_Z, - FINA_POS_X_COIL_X_CURRENT, - FINA_POS_X_COIL_Y_CURRENT, - FINA_POS_X_COIL_Z_CURRENT, - FINA_POS_X_COIL_X_TEMPERATURE, - FINA_POS_X_COIL_Y_TEMPERATURE, - FINA_POS_X_COIL_Z_TEMPERATURE, + FINA_POS_X_ERR, + FINA_POS_X_RAW_MAG_X, + FINA_POS_X_RAW_MAG_Y, + FINA_POS_X_RAW_MAG_Z, + FINA_POS_X_CAL_MAG_X, + FINA_POS_X_CAL_MAG_Y, + FINA_POS_X_CAL_MAG_Z, + FINA_POS_X_COIL_X_CURRENT, + FINA_POS_X_COIL_Y_CURRENT, + FINA_POS_X_COIL_Z_CURRENT, + FINA_POS_X_COIL_X_TEMPERATURE, + FINA_POS_X_COIL_Y_TEMPERATURE, + FINA_POS_X_COIL_Z_TEMPERATURE, - FINA_NEG_X_ERR, - FINA_NEG_X_RAW_MAG_X, - FINA_NEG_X_RAW_MAG_Y, - FINA_NEG_X_RAW_MAG_Z, - FINA_NEG_X_CAL_MAG_X, - FINA_NEG_X_CAL_MAG_Y, - FINA_NEG_X_CAL_MAG_Z, - FINA_NEG_X_COIL_X_CURRENT, - FINA_NEG_X_COIL_Y_CURRENT, - FINA_NEG_X_COIL_Z_CURRENT, - FINA_NEG_X_COIL_X_TEMPERATURE, - FINA_NEG_X_COIL_Y_TEMPERATURE, - FINA_NEG_X_COIL_Z_TEMPERATURE, + FINA_NEG_X_ERR, + FINA_NEG_X_RAW_MAG_X, + FINA_NEG_X_RAW_MAG_Y, + FINA_NEG_X_RAW_MAG_Z, + FINA_NEG_X_CAL_MAG_X, + FINA_NEG_X_CAL_MAG_Y, + FINA_NEG_X_CAL_MAG_Z, + FINA_NEG_X_COIL_X_CURRENT, + FINA_NEG_X_COIL_Y_CURRENT, + FINA_NEG_X_COIL_Z_CURRENT, + FINA_NEG_X_COIL_X_TEMPERATURE, + FINA_NEG_X_COIL_Y_TEMPERATURE, + FINA_NEG_X_COIL_Z_TEMPERATURE, - FINA_POS_Y_ERR, - FINA_POS_Y_RAW_MAG_X, - FINA_POS_Y_RAW_MAG_Y, - FINA_POS_Y_RAW_MAG_Z, - FINA_POS_Y_CAL_MAG_X, - FINA_POS_Y_CAL_MAG_Y, - FINA_POS_Y_CAL_MAG_Z, - FINA_POS_Y_COIL_X_CURRENT, - FINA_POS_Y_COIL_Y_CURRENT, - FINA_POS_Y_COIL_Z_CURRENT, - FINA_POS_Y_COIL_X_TEMPERATURE, - FINA_POS_Y_COIL_Y_TEMPERATURE, - FINA_POS_Y_COIL_Z_TEMPERATURE, + FINA_POS_Y_ERR, + FINA_POS_Y_RAW_MAG_X, + FINA_POS_Y_RAW_MAG_Y, + FINA_POS_Y_RAW_MAG_Z, + FINA_POS_Y_CAL_MAG_X, + FINA_POS_Y_CAL_MAG_Y, + FINA_POS_Y_CAL_MAG_Z, + FINA_POS_Y_COIL_X_CURRENT, + FINA_POS_Y_COIL_Y_CURRENT, + FINA_POS_Y_COIL_Z_CURRENT, + FINA_POS_Y_COIL_X_TEMPERATURE, + FINA_POS_Y_COIL_Y_TEMPERATURE, + FINA_POS_Y_COIL_Z_TEMPERATURE, - FINA_NEG_Y_ERR, - FINA_NEG_Y_RAW_MAG_X, - FINA_NEG_Y_RAW_MAG_Y, - FINA_NEG_Y_RAW_MAG_Z, - FINA_NEG_Y_CAL_MAG_X, - FINA_NEG_Y_CAL_MAG_Y, - FINA_NEG_Y_CAL_MAG_Z, - FINA_NEG_Y_COIL_X_CURRENT, - FINA_NEG_Y_COIL_Y_CURRENT, - FINA_NEG_Y_COIL_Z_CURRENT, - FINA_NEG_Y_COIL_X_TEMPERATURE, - FINA_NEG_Y_COIL_Y_TEMPERATURE, - FINA_NEG_Y_COIL_Z_TEMPERATURE, + FINA_NEG_Y_ERR, + FINA_NEG_Y_RAW_MAG_X, + FINA_NEG_Y_RAW_MAG_Y, + FINA_NEG_Y_RAW_MAG_Z, + FINA_NEG_Y_CAL_MAG_X, + FINA_NEG_Y_CAL_MAG_Y, + FINA_NEG_Y_CAL_MAG_Z, + FINA_NEG_Y_COIL_X_CURRENT, + FINA_NEG_Y_COIL_Y_CURRENT, + FINA_NEG_Y_COIL_Z_CURRENT, + FINA_NEG_Y_COIL_X_TEMPERATURE, + FINA_NEG_Y_COIL_Y_TEMPERATURE, + FINA_NEG_Y_COIL_Z_TEMPERATURE, - FINA_POS_Z_ERR, - FINA_POS_Z_RAW_MAG_X, - FINA_POS_Z_RAW_MAG_Y, - FINA_POS_Z_RAW_MAG_Z, - FINA_POS_Z_CAL_MAG_X, - FINA_POS_Z_CAL_MAG_Y, - FINA_POS_Z_CAL_MAG_Z, - FINA_POS_Z_COIL_X_CURRENT, - FINA_POS_Z_COIL_Y_CURRENT, - FINA_POS_Z_COIL_Z_CURRENT, - FINA_POS_Z_COIL_X_TEMPERATURE, - FINA_POS_Z_COIL_Y_TEMPERATURE, - FINA_POS_Z_COIL_Z_TEMPERATURE, + FINA_POS_Z_ERR, + FINA_POS_Z_RAW_MAG_X, + FINA_POS_Z_RAW_MAG_Y, + FINA_POS_Z_RAW_MAG_Z, + FINA_POS_Z_CAL_MAG_X, + FINA_POS_Z_CAL_MAG_Y, + FINA_POS_Z_CAL_MAG_Z, + FINA_POS_Z_COIL_X_CURRENT, + FINA_POS_Z_COIL_Y_CURRENT, + FINA_POS_Z_COIL_Z_CURRENT, + FINA_POS_Z_COIL_X_TEMPERATURE, + FINA_POS_Z_COIL_Y_TEMPERATURE, + FINA_POS_Z_COIL_Z_TEMPERATURE, - FINA_NEG_Z_ERR, - FINA_NEG_Z_RAW_MAG_X, - FINA_NEG_Z_RAW_MAG_Y, - FINA_NEG_Z_RAW_MAG_Z, - FINA_NEG_Z_CAL_MAG_X, - FINA_NEG_Z_CAL_MAG_Y, - FINA_NEG_Z_CAL_MAG_Z, - FINA_NEG_Z_COIL_X_CURRENT, - FINA_NEG_Z_COIL_Y_CURRENT, - FINA_NEG_Z_COIL_Z_CURRENT, - FINA_NEG_Z_COIL_X_TEMPERATURE, - FINA_NEG_Z_COIL_Y_TEMPERATURE, - FINA_NEG_Z_COIL_Z_TEMPERATURE, - }; + FINA_NEG_Z_ERR, + FINA_NEG_Z_RAW_MAG_X, + FINA_NEG_Z_RAW_MAG_Y, + FINA_NEG_Z_RAW_MAG_Z, + FINA_NEG_Z_CAL_MAG_X, + FINA_NEG_Z_CAL_MAG_Y, + FINA_NEG_Z_CAL_MAG_Z, + FINA_NEG_Z_COIL_X_CURRENT, + FINA_NEG_Z_COIL_Y_CURRENT, + FINA_NEG_Z_COIL_Z_CURRENT, + FINA_NEG_Z_COIL_X_TEMPERATURE, + FINA_NEG_Z_COIL_Y_TEMPERATURE, + FINA_NEG_Z_COIL_Z_TEMPERATURE, +}; -class EngHkDataset: public StaticLocalDataSet { -public: +class EngHkDataset : public StaticLocalDataSet { + public: + EngHkDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ENG_HK_DATA_SET_ID) {} - EngHkDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, ENG_HK_DATA_SET_ID) { - } + EngHkDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ENG_HK_DATA_SET_ID)) {} - EngHkDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, ENG_HK_DATA_SET_ID)) { - } - - lp_var_t digitalVoltageMv = lp_var_t(sid.objectId, DIGITAL_VOLTAGE_MV, - this); - lp_var_t analogVoltageMv = lp_var_t(sid.objectId, ANALOG_VOLTAGE_MV, this); - lp_var_t digitalCurrentmA = lp_var_t(sid.objectId, DIGITAL_CURRENT, this); - lp_var_t analogCurrentmA = lp_var_t(sid.objectId, ANALOG_CURRENT, this); - lp_var_t coilXCurrentmA = lp_var_t(sid.objectId, COIL_X_CURRENT, this); - lp_var_t coilYCurrentmA = lp_var_t(sid.objectId, COIL_Y_CURRENT, this); - lp_var_t coilZCurrentmA = lp_var_t(sid.objectId, COIL_Z_CURRENT, this); - /** All temperatures in [°C] */ - lp_var_t coilXTemperature = lp_var_t(sid.objectId, COIL_X_TEMPERATURE, - this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, COIL_Y_TEMPERATURE, - this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, COIL_Z_TEMPERATURE, - this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, MCU_TEMPERATURE, this); + lp_var_t digitalVoltageMv = lp_var_t(sid.objectId, DIGITAL_VOLTAGE_MV, this); + lp_var_t analogVoltageMv = lp_var_t(sid.objectId, ANALOG_VOLTAGE_MV, this); + lp_var_t digitalCurrentmA = lp_var_t(sid.objectId, DIGITAL_CURRENT, this); + lp_var_t analogCurrentmA = lp_var_t(sid.objectId, ANALOG_CURRENT, this); + lp_var_t coilXCurrentmA = lp_var_t(sid.objectId, COIL_X_CURRENT, this); + lp_var_t coilYCurrentmA = lp_var_t(sid.objectId, COIL_Y_CURRENT, this); + lp_var_t coilZCurrentmA = lp_var_t(sid.objectId, COIL_Z_CURRENT, this); + /** All temperatures in [°C] */ + lp_var_t coilXTemperature = lp_var_t(sid.objectId, COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = lp_var_t(sid.objectId, COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = lp_var_t(sid.objectId, COIL_Z_TEMPERATURE, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, MCU_TEMPERATURE, this); }; /** * @brief This dataset holds the last calibrated MTM measurement. */ -class CalibratedMtmMeasurementSet: public StaticLocalDataSet { -public: +class CalibratedMtmMeasurementSet : public StaticLocalDataSet { + public: + CalibratedMtmMeasurementSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CAL_MTM_SET) {} - CalibratedMtmMeasurementSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, CAL_MTM_SET) { - } + CalibratedMtmMeasurementSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) {} - CalibratedMtmMeasurementSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) { - } - - /** The unit of all measurements is nT */ - lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_CAL_X, this); - lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_CAL_Y, this); - lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_CAL_Z, this); - /** 1 if coils were actuating during measurement otherwise 0 */ - lp_var_t coilActuationStatus = lp_var_t(sid.objectId, ACTUATION_CAL_STATUS, - this); + /** The unit of all measurements is nT */ + lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_CAL_X, this); + lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_CAL_Y, this); + lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_CAL_Z, this); + /** 1 if coils were actuating during measurement otherwise 0 */ + lp_var_t coilActuationStatus = + lp_var_t(sid.objectId, ACTUATION_CAL_STATUS, this); }; /** * @brief This dataset holds the raw MTM measurements. */ -class RawMtmMeasurementSet: public StaticLocalDataSet { -public: +class RawMtmMeasurementSet : public StaticLocalDataSet { + public: + RawMtmMeasurementSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAW_MTM_SET) {} - RawMtmMeasurementSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RAW_MTM_SET) { - } + RawMtmMeasurementSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RAW_MTM_SET)) {} - RawMtmMeasurementSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RAW_MTM_SET)) { - } - - /** The unit of all measurements is nT */ - lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_RAW_X, this); - lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_RAW_Y, this); - lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_RAW_Z, this); - /** 1 if coils were actuating during measurement otherwise 0 */ - lp_var_t coilActuationStatus = lp_var_t(sid.objectId, ACTUATION_RAW_STATUS, - this); + /** The unit of all measurements is nT */ + lp_var_t mtmXnT = lp_var_t(sid.objectId, MTM_RAW_X, this); + lp_var_t mtmYnT = lp_var_t(sid.objectId, MTM_RAW_Y, this); + lp_var_t mtmZnT = lp_var_t(sid.objectId, MTM_RAW_Z, this); + /** 1 if coils were actuating during measurement otherwise 0 */ + lp_var_t coilActuationStatus = + lp_var_t(sid.objectId, ACTUATION_RAW_STATUS, this); }; - /** * @brief This class can be used to ease the generation of an action message commanding the * IMTQHandler to configure the magnettorquer with the desired dipoles. @@ -460,37 +442,32 @@ public: * the ipc store address in the action message. */ class CommandDipolePacket : public SerialLinkedListAdapter { -public: + public: + CommandDipolePacket() { setLinks(); } - CommandDipolePacket() { - setLinks(); - } - -private: - - /** - * @brief Constructor - * - * @param xDipole The dipole of the x coil in 10 ^ -4 * Am^2 - * @param yDipole The dipole of the y coil in 10 ^ -4 * Am^2 - * @param zDipole The dipole of the z coil in 10 ^ -4 * Am^2 - * @param duration The duration in milliseconds the dipole will be generated by the coils. - * When set to 0, the dipole will be generated until a new dipole actuation - * command is sent. - */ - CommandDipolePacket(uint16_t xDipole, uint16_t yDipole, uint16_t zDipole, uint16_t duration) : - xDipole(xDipole), yDipole(yDipole), zDipole(zDipole), duration(duration) { - } - void setLinks() { - setStart(&xDipole); - xDipole.setNext(&yDipole); - yDipole.setNext(&zDipole); - zDipole.setNext(&duration); - } - SerializeElement xDipole; - SerializeElement yDipole; - SerializeElement zDipole; - SerializeElement duration; + private: + /** + * @brief Constructor + * + * @param xDipole The dipole of the x coil in 10 ^ -4 * Am^2 + * @param yDipole The dipole of the y coil in 10 ^ -4 * Am^2 + * @param zDipole The dipole of the z coil in 10 ^ -4 * Am^2 + * @param duration The duration in milliseconds the dipole will be generated by the coils. + * When set to 0, the dipole will be generated until a new dipole actuation + * command is sent. + */ + CommandDipolePacket(uint16_t xDipole, uint16_t yDipole, uint16_t zDipole, uint16_t duration) + : xDipole(xDipole), yDipole(yDipole), zDipole(zDipole), duration(duration) {} + void setLinks() { + setStart(&xDipole); + xDipole.setNext(&yDipole); + yDipole.setNext(&zDipole); + zDipole.setNext(&duration); + } + SerializeElement xDipole; + SerializeElement yDipole; + SerializeElement zDipole; + SerializeElement duration; }; /** @@ -507,79 +484,67 @@ private: * 2. +X actuation * 3. All coils off (FINA step) */ -class PosXSelfTestSet: public StaticLocalDataSet { -public: +class PosXSelfTestSet : public StaticLocalDataSet { + public: + PosXSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_X_TEST_DATASET) {} - PosXSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_X_TEST_DATASET) { - } + PosXSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_X_TEST_DATASET)) {} - PosXSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_X_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_X_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_X_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_X_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_X_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_X_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_X_COIL_Z_TEMPERATURE, this); + /** +X block */ + lp_var_t err = lp_var_t(sid.objectId, POS_X_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_X_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_X_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_X_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_X_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_X_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_X_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_X_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_X_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_X_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_X_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_X_COIL_Z_TEMPERATURE, this); - /** +X block */ - lp_var_t err = lp_var_t(sid.objectId, POS_X_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_X_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_X_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_X_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_X_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_X_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_X_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_X_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_X_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_X_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_X_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_X_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_X_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_X_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_X_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_X_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_X_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_X_COIL_Z_TEMPERATURE, this); }; /** @@ -596,82 +561,69 @@ public: * 2. -X actuation * 3. All coils off (FINA step) */ -class NegXSelfTestSet: public StaticLocalDataSet { -public: +class NegXSelfTestSet : public StaticLocalDataSet { + public: + NegXSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_X_TEST_DATASET) {} - NegXSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_X_TEST_DATASET) { - } + NegXSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_X_TEST_DATASET)) {} - NegXSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_X_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_X_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_X_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_X_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_X_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_X_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_X_COIL_Z_TEMPERATURE, this); + /** -X block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_X_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_X_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_X_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_X_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_X_COIL_Z_TEMPERATURE, this); - /** -X block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_X_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_X_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_X_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_X_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_X_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_X_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_X_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_X_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_X_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_X_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_X_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_X_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_X_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_X_COIL_Z_TEMPERATURE, this); }; - /** * @brief This dataset can be used to store the self test results of the +Y self test. * @@ -686,79 +638,67 @@ public: * 2. +Y actuation * 3. All coils off (FINA step) */ -class PosYSelfTestSet: public StaticLocalDataSet { -public: +class PosYSelfTestSet : public StaticLocalDataSet { + public: + PosYSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_Y_TEST_DATASET) {} - PosYSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_Y_TEST_DATASET) { - } + PosYSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Y_TEST_DATASET)) {} - PosYSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Y_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Y_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Y_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Y_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Y_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Y_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_Y_COIL_Z_TEMPERATURE, this); + /** +Y block */ + lp_var_t err = lp_var_t(sid.objectId, POS_Y_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Y_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_Y_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Y_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_Y_COIL_Z_TEMPERATURE, this); - /** +Y block */ - lp_var_t err = lp_var_t(sid.objectId, POS_Y_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Y_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Y_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_Y_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Y_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Y_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Y_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_Y_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Y_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_Y_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Y_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Y_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Y_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_Y_COIL_Z_TEMPERATURE, this); }; /** @@ -775,79 +715,67 @@ public: * 2. -Y actuation * 3. All coils off (FINA step) */ -class NegYSelfTestSet: public StaticLocalDataSet { -public: +class NegYSelfTestSet : public StaticLocalDataSet { + public: + NegYSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_Y_TEST_DATASET) {} - NegYSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_Y_TEST_DATASET) { - } + NegYSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Y_TEST_DATASET)) {} - NegYSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Y_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Y_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Y_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Y_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_Y_COIL_Z_TEMPERATURE, this); + /** -Y block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_Y_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_Y_COIL_Z_TEMPERATURE, this); - /** -Y block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_Y_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Y_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Y_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_Y_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Y_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_Y_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Y_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Y_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_Y_COIL_Z_TEMPERATURE, this); }; /** @@ -864,79 +792,67 @@ public: * 2. +Z actuation * 3. All coils off (FINA step) */ -class PosZSelfTestSet: public StaticLocalDataSet { -public: +class PosZSelfTestSet : public StaticLocalDataSet { + public: + PosZSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::POS_Z_TEST_DATASET) {} - PosZSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::POS_Z_TEST_DATASET) { - } + PosZSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Z_TEST_DATASET)) {} - PosZSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::POS_Z_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Z_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_POS_Z_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_POS_Z_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_POS_Z_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_POS_Z_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_POS_Z_COIL_Z_TEMPERATURE, this); + /** +Z block */ + lp_var_t err = lp_var_t(sid.objectId, POS_Z_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Z_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, POS_Z_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Z_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, POS_Z_COIL_Z_TEMPERATURE, this); - /** +Z block */ - lp_var_t err = lp_var_t(sid.objectId, POS_Z_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, POS_Z_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, POS_Z_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, POS_Z_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, POS_Z_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, POS_Z_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, POS_Z_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - POS_Z_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Z_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_POS_Z_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_POS_Z_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_POS_Z_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_POS_Z_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_POS_Z_COIL_Z_TEMPERATURE, this); }; /** @@ -953,82 +869,69 @@ public: * 2. -Z actuation * 3. All coils off (FINA step) */ -class NegZSelfTestSet: public StaticLocalDataSet { -public: +class NegZSelfTestSet : public StaticLocalDataSet { + public: + NegZSelfTestSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, IMTQ::NEG_Z_TEST_DATASET) {} - NegZSelfTestSet(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, IMTQ::NEG_Z_TEST_DATASET) { - } + NegZSelfTestSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Z_TEST_DATASET)) {} - NegZSelfTestSet(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, IMTQ::NEG_Z_TEST_DATASET)) { - } + /** INIT block */ + lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Z_ERR, this); + lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_X, this); + lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Y, this); + lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Z, this); + lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_X, this); + lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Y, this); + lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Z, this); + lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_CURRENT, this); + lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_CURRENT, this); + lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_CURRENT, this); + lp_var_t initCoilXTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t initCoilYTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t initCoilZTemperature = + lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_TEMPERATURE, this); - /** INIT block */ - lp_var_t initErr = lp_var_t(sid.objectId, INIT_NEG_Z_ERR, this); - lp_var_t initRawMagX = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_X, this); - lp_var_t initRawMagY = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Y, this); - lp_var_t initRawMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_RAW_MAG_Z, this); - lp_var_t initCalMagX = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_X, this); - lp_var_t initCalMagY = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Y, this); - lp_var_t initCalMagZ = lp_var_t(sid.objectId, INIT_NEG_Z_CAL_MAG_Z, this); - lp_var_t initCoilXCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_X_CURRENT, - this); - lp_var_t initCoilYCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t initCoilZCurrent = lp_var_t(sid.objectId, INIT_NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t initCoilXTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t initCoilYTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t initCoilZTemperature = lp_var_t(sid.objectId, - INIT_NEG_Z_COIL_Z_TEMPERATURE, this); + /** +Z block */ + lp_var_t err = lp_var_t(sid.objectId, NEG_Z_ERR, this); + lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_X, this); + lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Y, this); + lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Z, this); + lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_X, this); + lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Y, this); + lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Z, this); + lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_X_CURRENT, this); + lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Y_CURRENT, this); + lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Z_CURRENT, this); + lp_var_t coilXTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t coilYTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t coilZTemperature = + lp_var_t(sid.objectId, NEG_Z_COIL_Z_TEMPERATURE, this); - /** +Z block */ - lp_var_t err = lp_var_t(sid.objectId, NEG_Z_ERR, this); - lp_var_t rawMagX = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_X, this); - lp_var_t rawMagY = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Y, this); - lp_var_t rawMagZ = lp_var_t(sid.objectId, NEG_Z_RAW_MAG_Z, this); - lp_var_t calMagX = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_X, this); - lp_var_t calMagY = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Y, this); - lp_var_t calMagZ = lp_var_t(sid.objectId, NEG_Z_CAL_MAG_Z, this); - lp_var_t coilXCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_X_CURRENT, - this); - lp_var_t coilYCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t coilZCurrent = lp_var_t(sid.objectId, NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t coilXTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t coilYTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t coilZTemperature = lp_var_t(sid.objectId, - NEG_Z_COIL_Z_TEMPERATURE, this); - - /** FINA block */ - lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Z_ERR, this); - lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_X, this); - lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Y, this); - lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Z, this); - lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_X, this); - lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Y, this); - lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Z, this); - lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_CURRENT, - this); - lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_CURRENT, - this); - lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_CURRENT, - this); - lp_var_t finaCoilXTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_X_TEMPERATURE, this); - lp_var_t finaCoilYTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_Y_TEMPERATURE, this); - lp_var_t finaCoilZTemperature = lp_var_t(sid.objectId, - FINA_NEG_Z_COIL_Z_TEMPERATURE, this); + /** FINA block */ + lp_var_t finaErr = lp_var_t(sid.objectId, FINA_NEG_Z_ERR, this); + lp_var_t finaRawMagX = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_X, this); + lp_var_t finaRawMagY = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Y, this); + lp_var_t finaRawMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_RAW_MAG_Z, this); + lp_var_t finaCalMagX = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_X, this); + lp_var_t finaCalMagY = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Y, this); + lp_var_t finaCalMagZ = lp_var_t(sid.objectId, FINA_NEG_Z_CAL_MAG_Z, this); + lp_var_t finaCoilXCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_CURRENT, this); + lp_var_t finaCoilYCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_CURRENT, this); + lp_var_t finaCoilZCurrent = lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_CURRENT, this); + lp_var_t finaCoilXTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_X_TEMPERATURE, this); + lp_var_t finaCoilYTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Y_TEMPERATURE, this); + lp_var_t finaCoilZTemperature = + lp_var_t(sid.objectId, FINA_NEG_Z_COIL_Z_TEMPERATURE, this); }; -} - +} // namespace IMTQ #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_IMTQDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/Max31865Definitions.h b/mission/devices/devicedefinitions/Max31865Definitions.h index c9c8255e..58faaf97 100644 --- a/mission/devices/devicedefinitions/Max31865Definitions.h +++ b/mission/devices/devicedefinitions/Max31865Definitions.h @@ -1,18 +1,15 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ -#include #include +#include #include + #include "objects/systemObjectList.h" namespace Max31865Definitions { -enum PoolIds: lp_id_t { - RTD_VALUE, - TEMPERATURE_C, - FAULT_BYTE -}; +enum PoolIds : lp_id_t { RTD_VALUE, TEMPERATURE_C, FAULT_BYTE }; static constexpr DeviceCommandId_t CONFIG_CMD = 0x80; static constexpr DeviceCommandId_t WRITE_HIGH_THRESHOLD = 0x83; @@ -31,35 +28,26 @@ static constexpr uint8_t CLEAR_FAULT_BIT_VAL = 0b0000'0010; static constexpr size_t MAX_REPLY_SIZE = 5; -class Max31865Set: - public StaticLocalDataSet { -public: - /** - * Constructor used by owner and data creators like device handlers. - * @param owner - * @param setId - */ - Max31865Set(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, MAX31865_SET_ID) { - } +class Max31865Set : public StaticLocalDataSet { + public: + /** + * Constructor used by owner and data creators like device handlers. + * @param owner + * @param setId + */ + Max31865Set(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, MAX31865_SET_ID) {} - /** - * Constructor used by data users like controllers. - * @param sid - */ - Max31865Set(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) { - } + /** + * Constructor used by data users like controllers. + * @param sid + */ + Max31865Set(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, MAX31865_SET_ID)) {} - lp_var_t rtdValue = lp_var_t(sid.objectId, - PoolIds::RTD_VALUE, this); - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - PoolIds::TEMPERATURE_C, this); - lp_var_t errorByte = lp_var_t(sid.objectId, - PoolIds::FAULT_BYTE, this); + lp_var_t rtdValue = lp_var_t(sid.objectId, PoolIds::RTD_VALUE, this); + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); + lp_var_t errorByte = lp_var_t(sid.objectId, PoolIds::FAULT_BYTE, this); }; -} +} // namespace Max31865Definitions #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */ - diff --git a/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h index 2b9466ab..2c8a081c 100644 --- a/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -1,172 +1,166 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ -#include #include #include +#include namespace PLOC_MPSOC { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t TC_MEM_WRITE = 0x1; - static const DeviceCommandId_t TC_MEM_READ = 0x2; - static const DeviceCommandId_t ACK_REPORT = 0x3; - static const DeviceCommandId_t EXE_REPORT = 0x5; - static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t TC_MEM_WRITE = 0x1; +static const DeviceCommandId_t TC_MEM_READ = 0x2; +static const DeviceCommandId_t ACK_REPORT = 0x3; +static const DeviceCommandId_t EXE_REPORT = 0x5; +static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 0x6; - static const uint16_t SIZE_ACK_REPORT = 14; - static const uint16_t SIZE_EXE_REPORT = 14; - static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; +static const uint16_t SIZE_ACK_REPORT = 14; +static const uint16_t SIZE_EXE_REPORT = 14; +static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; - /** - * SpacePacket apids of PLOC telecommands and telemetry. - */ - static const uint16_t APID_TC_MEM_WRITE = 0x714; - static const uint16_t APID_TC_MEM_READ = 0x715; - static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404; - static const uint16_t APID_ACK_SUCCESS = 0x400; - static const uint16_t APID_ACK_FAILURE = 0x401; - static const uint16_t APID_EXE_SUCCESS = 0x402; - static const uint16_t APID_EXE_FAILURE = 0x403; +/** + * SpacePacket apids of PLOC telecommands and telemetry. + */ +static const uint16_t APID_TC_MEM_WRITE = 0x714; +static const uint16_t APID_TC_MEM_READ = 0x715; +static const uint16_t APID_TM_MEMORY_READ_REPORT = 0x404; +static const uint16_t APID_ACK_SUCCESS = 0x400; +static const uint16_t APID_ACK_FAILURE = 0x401; +static const uint16_t APID_EXE_SUCCESS = 0x402; +static const uint16_t APID_EXE_FAILURE = 0x403; - /** Offset from first byte in Space packet to first byte of data field */ - static const uint8_t DATA_FIELD_OFFSET = 6; +/** Offset from first byte in Space packet to first byte of data field */ +static const uint8_t DATA_FIELD_OFFSET = 6; - /** - * The size of payload data which will be forwarded to the requesting object. e.g. PUS Service - * 8. - */ - static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10; +/** + * The size of payload data which will be forwarded to the requesting object. e.g. PUS Service + * 8. + */ +static const uint8_t SIZE_MEM_READ_REPORT_DATA = 10; - /** - * PLOC space packet length for fixed size packets. This is the size of the whole packet data - * field. For the length field in the space packet this size will be substracted by one. - */ - static const uint16_t LENGTH_TC_MEM_WRITE = 12; - static const uint16_t LENGTH_TC_MEM_READ = 8; +/** + * PLOC space packet length for fixed size packets. This is the size of the whole packet data + * field. For the length field in the space packet this size will be substracted by one. + */ +static const uint16_t LENGTH_TC_MEM_WRITE = 12; +static const uint16_t LENGTH_TC_MEM_READ = 8; - static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT; - static const size_t MAX_COMMAND_SIZE = 18; +static const size_t MAX_REPLY_SIZE = SIZE_TM_MEM_READ_REPORT; +static const size_t MAX_COMMAND_SIZE = 18; - /** - * @brief This class helps to build the memory read command for the PLOC. - * - * @details The last two bytes of the packet data field contain a CRC calculated over the whole - * space packet. This is the CRC-16-CCITT as specified in - * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. - */ - class TcMemRead : public SpacePacket { - public: +/** + * @brief This class helps to build the memory read command for the PLOC. + * + * @details The last two bytes of the packet data field contain a CRC calculated over the whole + * space packet. This is the CRC-16-CCITT as specified in + * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. + */ +class TcMemRead : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param memAddr The memory address to read from. + */ + TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) + : SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) { + fillPacketDataField(&memAddr); + } - /** - * @brief Constructor - * - * @param memAddr The memory address to read from. - */ - TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) : - SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) { - fillPacketDataField(&memAddr); - } + private: + /** + * @brief This function builds the packet data field for the mem read command. + * + * @param memAddrPtr Pointer to the memory address to read from. + */ + void fillPacketDataField(const uint32_t* memAddrPtr) { + /* Add memAddr to packet data field */ + size_t serializedSize = 0; + uint8_t* memoryAddressPos = this->localData.fields.buffer; + SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, + sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE); - private: + /* Add memLen to packet data field */ + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - /** - * @brief This function builds the packet data field for the mem read command. - * - * @param memAddrPtr Pointer to the memory address to read from. - */ - void fillPacketDataField(const uint32_t* memAddrPtr) { - /* Add memAddr to packet data field */ - size_t serializedSize = 0; - uint8_t* memoryAddressPos = this->localData.fields.buffer; - SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, - sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE); - /* Add memLen to packet data field */ - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; + /* Add crc to packet data field of space packet */ + serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE); + static const uint8_t OFFSET_MEM_LEN_FIELD = 4; + static const uint8_t CRC_OFFSET = 6; +}; - /* Add crc to packet data field of space packet */ - serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, - sizeof(crc), SerializeIF::Endianness::BIG); - } +/** + * @brief This class helps to generate the space packet to write to a memory address within + * the PLOC. + * @details The last two bytes of the packet data field contain a CRC calculated over the whole + * space packet. This is the CRC-16-CCITT as specified in + * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. + */ +class TcMemWrite : public SpacePacket { + public: + /** + * @brief Constructor + * + * @param memAddr The PLOC memory address where to write to. + * @param memoryData The data to write to the specified memory address. + * @param sequenceCount The subsequence count. Must be incremented with each new packet. + */ + TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) + : SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) { + fillPacketDataField(&memAddr, &memoryData); + } - static const uint8_t OFFSET_MEM_LEN_FIELD = 4; - static const uint8_t CRC_OFFSET = 6; + private: + /** + * @brief This function builds the packet data field for the mem write command. + * + * @param memAddrPtr Pointer to the PLOC memory address where to write to. + * @param memoryDataPtr Pointer to the memoryData to write + */ + void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) { + /* Add memAddr to packet data field */ + size_t serializedSize = 0; + uint8_t* memoryAddressPos = this->localData.fields.buffer; + SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, + sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); - }; + /* Add memLen to packet data field */ + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; + this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - /** - * @brief This class helps to generate the space packet to write to a memory address within - * the PLOC. - * @details The last two bytes of the packet data field contain a CRC calculated over the whole - * space packet. This is the CRC-16-CCITT as specified in - * ECSS-E-ST-70-41C Telemetry and telecommand packet utilization. - */ - class TcMemWrite : public SpacePacket { - public: - /** - * @brief Constructor - * - * @param memAddr The PLOC memory address where to write to. - * @param memoryData The data to write to the specified memory address. - * @param sequenceCount The subsequence count. Must be incremented with each new packet. - */ - TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) : - SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) { - fillPacketDataField(&memAddr, &memoryData); - } + /* Add memData to packet data field */ + serializedSize = 0; + uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD; + SerializeAdapter::serialize(memoryDataPtr, &memoryDataPos, &serializedSize, + sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG); - private: + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE); - /** - * @brief This function builds the packet data field for the mem write command. - * - * @param memAddrPtr Pointer to the PLOC memory address where to write to. - * @param memoryDataPtr Pointer to the memoryData to write - */ - void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) { + serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + /* Add crc to packet data field of space packet */ + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } - /* Add memAddr to packet data field */ - size_t serializedSize = 0; - uint8_t* memoryAddressPos = this->localData.fields.buffer; - SerializeAdapter::serialize(memAddrPtr, &memoryAddressPos, &serializedSize, - sizeof(*memAddrPtr), SerializeIF::Endianness::BIG); - - /* Add memLen to packet data field */ - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1; - this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0; - - /* Add memData to packet data field */ - serializedSize = 0; - uint8_t* memoryDataPos = this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD; - SerializeAdapter::serialize(memoryDataPtr, &memoryDataPos, &serializedSize, - sizeof(*memoryDataPtr), SerializeIF::Endianness::BIG); - - /* Calculate crc */ - uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, - sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE); - - serializedSize = 0; - uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; - /* Add crc to packet data field of space packet */ - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, - sizeof(crc), SerializeIF::Endianness::BIG); - } - - /** Offsets from base address of packet data field */ - static const uint8_t OFFSET_MEM_LEN_FIELD = 4; - static const uint8_t OFFSET_MEM_DATA_FIELD = 6; - static const uint8_t CRC_OFFSET = 10; - }; - -} + /** Offsets from base address of packet data field */ + static const uint8_t OFFSET_MEM_LEN_FIELD = 4; + static const uint8_t OFFSET_MEM_DATA_FIELD = 6; + static const uint8_t CRC_OFFSET = 10; +}; +} // namespace PLOC_MPSOC #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/RadSensorDefinitions.h b/mission/devices/devicedefinitions/RadSensorDefinitions.h index d3c8e876..ab49b61b 100644 --- a/mission/devices/devicedefinitions/RadSensorDefinitions.h +++ b/mission/devices/devicedefinitions/RadSensorDefinitions.h @@ -3,84 +3,79 @@ namespace RAD_SENSOR { - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - /** - * This command initiates the ADC conversion for all channels including the internal - * temperature sensor. - */ - static const DeviceCommandId_t WRITE_SETUP = 0x1; - static const DeviceCommandId_t START_CONVERSION = 0x2; - static const DeviceCommandId_t READ_CONVERSIONS = 0x3; +/** + * This command initiates the ADC conversion for all channels including the internal + * temperature sensor. + */ +static const DeviceCommandId_t WRITE_SETUP = 0x1; +static const DeviceCommandId_t START_CONVERSION = 0x2; +static const DeviceCommandId_t READ_CONVERSIONS = 0x3; - /** - * @brief This is the configuration byte which will be written to the setup register after - * power on. - * - * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte - * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay - * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing - * Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register - * - */ - static const uint8_t SETUP_DEFINITION = 0b01101000; +/** + * @brief This is the configuration byte which will be written to the setup register after + * power on. + * + * @note Bit1 (DIFFSEL1) - Bit0 (DIFFSEL0): 0b00, no data follows the setup byte + * Bit3 (REFSEL1) - Bit2 (REFSEL0): 0b10, internal reference, no wake-up delay + * Bit5 (CLKSEL1) - Bit4 (CLKSEL0): 0b10, MAX1227 uses internal oscillator for timing + * Bit7 - Bit6: 0b01, tells MAX1227 that this is the setup register + * + */ +static const uint8_t SETUP_DEFINITION = 0b01101000; - /** - * @brief This value will always be written to the ADC conversion register to specify the - * conversions to perform. - * @details Bit0: 1 - Enables temperature conversion - * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N) - * Bit6 - Bit3 defines N: 0b0111 (N = 7) - * Bit7: Always 1. Tells the ADC that this is the conversion register. - */ - static const uint8_t CONVERSION_DEFINITION = 0b10111001; +/** + * @brief This value will always be written to the ADC conversion register to specify the + * conversions to perform. + * @details Bit0: 1 - Enables temperature conversion + * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N) + * Bit6 - Bit3 defines N: 0b0111 (N = 7) + * Bit7: Always 1. Tells the ADC that this is the conversion register. + */ +static const uint8_t CONVERSION_DEFINITION = 0b10111001; // static const uint8_t CONVERSION_DEFINITION = 0b10111111; - /** - * @brief Writing this value resets the fifo of the MAX1227. - */ - static const uint8_t RESET_DEFINITION = 0b00011000; +/** + * @brief Writing this value resets the fifo of the MAX1227. + */ +static const uint8_t RESET_DEFINITION = 0b00011000; - static const uint8_t DUMMY_BYTE = 0xFF; +static const uint8_t DUMMY_BYTE = 0xFF; - static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; +static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; - static const uint8_t DATASET_ENTRIES = 7; - /** - * One temperature value and conversions for AIN0 - AIN7 - */ - static const uint8_t READ_SIZE = 18; +static const uint8_t DATASET_ENTRIES = 7; +/** + * One temperature value and conversions for AIN0 - AIN7 + */ +static const uint8_t READ_SIZE = 18; - enum Max1227PoolIds: lp_id_t { - TEMPERATURE_C, - AIN0, - AIN1, - AIN4, - AIN5, - AIN6, - AIN7, - }; - -class RadSensorDataset: public StaticLocalDataSet { -public: - - RadSensorDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) { - } - - RadSensorDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); - lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); - lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); - lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); - lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); - lp_var_t ain6 = lp_var_t(sid.objectId, AIN6, this); - lp_var_t ain7 = lp_var_t(sid.objectId, AIN7, this); +enum Max1227PoolIds : lp_id_t { + TEMPERATURE_C, + AIN0, + AIN1, + AIN4, + AIN5, + AIN6, + AIN7, }; -} +class RadSensorDataset : public StaticLocalDataSet { + public: + RadSensorDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RAD_SENSOR_DATA_SET_ID) {} + + RadSensorDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, RAD_SENSOR_DATA_SET_ID)) {} + + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); + lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); + lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); + lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); + lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); + lp_var_t ain6 = lp_var_t(sid.objectId, AIN6, this); + lp_var_t ain7 = lp_var_t(sid.objectId, AIN7, this); +}; +} // namespace RAD_SENSOR #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RADSENSOR_H_ */ diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index b8905002..c25e3f09 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -1,66 +1,61 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ -#include #include +#include #include + #include "objects/systemObjectList.h" namespace RwDefinitions { -static const uint32_t SPI_REPLY_DELAY = 70000; //us +static const uint32_t SPI_REPLY_DELAY = 70000; // us -enum PoolIds: lp_id_t { - TEMPERATURE_C, - CURR_SPEED, - REFERENCE_SPEED, - STATE, - CLC_MODE, - LAST_RESET_STATUS, - CURRRENT_RESET_STATUS, - TM_LAST_RESET_STATUS, - TM_MCU_TEMPERATURE, - PRESSURE_SENSOR_TEMPERATURE, - PRESSURE, - TM_RW_STATE, - TM_CLC_MODE, - TM_RW_CURR_SPEED, - TM_RW_REF_SPEED, - INVALID_CRC_PACKETS, - INVALID_LEN_PACKETS, - INVALID_CMD_PACKETS, - EXECUTED_REPLIES, - COMMAND_REPLIES, - UART_BYTES_WRITTEN, - UART_BYTES_READ, - UART_PARITY_ERRORS, - UART_NOISE_ERRORS, - UART_FRAME_ERRORS, - UART_REG_OVERRUN_ERRORS, - UART_TOTAL_ERRORS, - TOTAL_ERRORS, - SPI_BYTES_WRITTEN, - SPI_BYTES_READ, - SPI_REG_OVERRUN_ERRORS, - SPI_TOTAL_ERRORS +enum PoolIds : lp_id_t { + TEMPERATURE_C, + CURR_SPEED, + REFERENCE_SPEED, + STATE, + CLC_MODE, + LAST_RESET_STATUS, + CURRRENT_RESET_STATUS, + TM_LAST_RESET_STATUS, + TM_MCU_TEMPERATURE, + PRESSURE_SENSOR_TEMPERATURE, + PRESSURE, + TM_RW_STATE, + TM_CLC_MODE, + TM_RW_CURR_SPEED, + TM_RW_REF_SPEED, + INVALID_CRC_PACKETS, + INVALID_LEN_PACKETS, + INVALID_CMD_PACKETS, + EXECUTED_REPLIES, + COMMAND_REPLIES, + UART_BYTES_WRITTEN, + UART_BYTES_READ, + UART_PARITY_ERRORS, + UART_NOISE_ERRORS, + UART_FRAME_ERRORS, + UART_REG_OVERRUN_ERRORS, + UART_TOTAL_ERRORS, + TOTAL_ERRORS, + SPI_BYTES_WRITTEN, + SPI_BYTES_READ, + SPI_REG_OVERRUN_ERRORS, + SPI_TOTAL_ERRORS }; -enum States: uint8_t { - STATE_ERROR, - IDLE, - COASTING, - RUNNING_SPEED_STABLE, - RUNNING_SPEED_CHANGING -}; +enum States : uint8_t { STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, RUNNING_SPEED_CHANGING }; -enum LastResetStatus: uint8_t { - CLEARED = 0, - PIN_RESET = 1, - POR_PDR_BOR_RESET = 2, - SOFTWARE_RESET = 4, - INDEPENDENT_WATCHDOG_RESET = 8, - WINDOW_WATCHDOG_RESET = 16, - LOW_POWER_RESET = 32 +enum LastResetStatus : uint8_t { + CLEARED = 0, + PIN_RESET = 1, + POR_PDR_BOR_RESET = 2, + SOFTWARE_RESET = 4, + INDEPENDENT_WATCHDOG_RESET = 8, + WINDOW_WATCHDOG_RESET = 16, + LOW_POWER_RESET = 32 }; static const DeviceCommandId_t RESET_MCU = 1; @@ -103,66 +98,45 @@ static const uint8_t TM_SET_ENTRIES = 24; /** * @brief This dataset can be used to store the temperature of a reaction wheel. */ -class TemperatureSet: - public StaticLocalDataSet { -public: +class TemperatureSet : public StaticLocalDataSet { + public: + TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} - TemperatureSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { - } + TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} - TemperatureSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - PoolIds::TEMPERATURE_C, this); + lp_var_t temperatureCelcius = + lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); }; /** * @brief This dataset can be used to store the reaction wheel status. */ -class StatusSet: - public StaticLocalDataSet { -public: +class StatusSet : public StaticLocalDataSet { + public: + StatusSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, STATUS_SET_ID) {} - StatusSet(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, STATUS_SET_ID) { - } + StatusSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) {} - StatusSet(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) { - } - - lp_var_t currSpeed = lp_var_t(sid.objectId, - PoolIds::CURR_SPEED, this); - lp_var_t referenceSpeed = lp_var_t(sid.objectId, - PoolIds::REFERENCE_SPEED, this); - lp_var_t state = lp_var_t(sid.objectId, - PoolIds::STATE, this); - lp_var_t clcMode = lp_var_t(sid.objectId, - PoolIds::CLC_MODE, this); + lp_var_t currSpeed = lp_var_t(sid.objectId, PoolIds::CURR_SPEED, this); + lp_var_t referenceSpeed = + lp_var_t(sid.objectId, PoolIds::REFERENCE_SPEED, this); + lp_var_t state = lp_var_t(sid.objectId, PoolIds::STATE, this); + lp_var_t clcMode = lp_var_t(sid.objectId, PoolIds::CLC_MODE, this); }; /** * @brief This dataset stores the last reset status. */ -class LastResetSatus: - public StaticLocalDataSet { -public: +class LastResetSatus : public StaticLocalDataSet { + public: + LastResetSatus(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LAST_RESET_ID) {} - LastResetSatus(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, LAST_RESET_ID) { - } + LastResetSatus(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) {} - LastResetSatus(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) { - } - - lp_var_t lastResetStatus = lp_var_t(sid.objectId, - PoolIds::LAST_RESET_STATUS, this); - lp_var_t currentResetStatus = lp_var_t(sid.objectId, - PoolIds::CURRRENT_RESET_STATUS, this); + lp_var_t lastResetStatus = + lp_var_t(sid.objectId, PoolIds::LAST_RESET_STATUS, this); + lp_var_t currentResetStatus = + lp_var_t(sid.objectId, PoolIds::CURRRENT_RESET_STATUS, this); }; /** @@ -170,69 +144,57 @@ public: * reaction wheels. https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/ * EIVE_IRS/Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622 */ -class TmDataset: - public StaticLocalDataSet { -public: +class TmDataset : public StaticLocalDataSet { + public: + TmDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TM_SET_ID) {} - TmDataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TM_SET_ID) { - } + TmDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) {} - TmDataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) { - } - - lp_var_t lastResetStatus = lp_var_t(sid.objectId, - PoolIds::TM_LAST_RESET_STATUS, this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, - PoolIds::TM_MCU_TEMPERATURE, this); - lp_var_t pressureSensorTemperature = lp_var_t(sid.objectId, - PoolIds::PRESSURE_SENSOR_TEMPERATURE, this); - lp_var_t pressure = lp_var_t(sid.objectId, - PoolIds::PRESSURE, this); - lp_var_t rwState = lp_var_t(sid.objectId, - PoolIds::TM_RW_STATE, this); - lp_var_t rwClcMode = lp_var_t(sid.objectId, - PoolIds::TM_CLC_MODE, this); - lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, - PoolIds::TM_RW_CURR_SPEED, this); - lp_var_t rwRefSpeed = lp_var_t(sid.objectId, - PoolIds::TM_RW_REF_SPEED, this); - lp_var_t numOfInvalidCrcPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_CRC_PACKETS, this); - lp_var_t numOfInvalidLenPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_LEN_PACKETS, this); - lp_var_t numOfInvalidCmdPackets = lp_var_t(sid.objectId, - PoolIds::INVALID_CMD_PACKETS, this); - lp_var_t numOfCmdExecutedReplies = lp_var_t(sid.objectId, - PoolIds::EXECUTED_REPLIES, this); - lp_var_t numOfCmdReplies = lp_var_t(sid.objectId, - PoolIds::COMMAND_REPLIES, this); - lp_var_t uartNumOfBytesWritten = lp_var_t(sid.objectId, - PoolIds::UART_BYTES_WRITTEN, this); - lp_var_t uartNumOfBytesRead = lp_var_t(sid.objectId, - PoolIds::UART_BYTES_READ, this); - lp_var_t uartNumOfParityErrors = lp_var_t(sid.objectId, - PoolIds::UART_PARITY_ERRORS, this); - lp_var_t uartNumOfNoiseErrors = lp_var_t(sid.objectId, - PoolIds::UART_NOISE_ERRORS, this); - lp_var_t uartNumOfFrameErrors = lp_var_t(sid.objectId, - PoolIds::UART_FRAME_ERRORS, this); - lp_var_t uartNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, - PoolIds::UART_REG_OVERRUN_ERRORS, this); - lp_var_t uartTotalNumOfErrors = lp_var_t(sid.objectId, - PoolIds::UART_TOTAL_ERRORS, this); - lp_var_t spiNumOfBytesWritten = lp_var_t(sid.objectId, - PoolIds::SPI_BYTES_WRITTEN, this); - lp_var_t spiNumOfBytesRead = lp_var_t(sid.objectId, - PoolIds::SPI_BYTES_READ, this); - lp_var_t spiNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, - PoolIds::SPI_REG_OVERRUN_ERRORS, this); - lp_var_t spiTotalNumOfErrors = lp_var_t(sid.objectId, - PoolIds::SPI_TOTAL_ERRORS, this); + lp_var_t lastResetStatus = + lp_var_t(sid.objectId, PoolIds::TM_LAST_RESET_STATUS, this); + lp_var_t mcuTemperature = + lp_var_t(sid.objectId, PoolIds::TM_MCU_TEMPERATURE, this); + lp_var_t pressureSensorTemperature = + lp_var_t(sid.objectId, PoolIds::PRESSURE_SENSOR_TEMPERATURE, this); + lp_var_t pressure = lp_var_t(sid.objectId, PoolIds::PRESSURE, this); + lp_var_t rwState = lp_var_t(sid.objectId, PoolIds::TM_RW_STATE, this); + lp_var_t rwClcMode = lp_var_t(sid.objectId, PoolIds::TM_CLC_MODE, this); + lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, PoolIds::TM_RW_CURR_SPEED, this); + lp_var_t rwRefSpeed = lp_var_t(sid.objectId, PoolIds::TM_RW_REF_SPEED, this); + lp_var_t numOfInvalidCrcPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_CRC_PACKETS, this); + lp_var_t numOfInvalidLenPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_LEN_PACKETS, this); + lp_var_t numOfInvalidCmdPackets = + lp_var_t(sid.objectId, PoolIds::INVALID_CMD_PACKETS, this); + lp_var_t numOfCmdExecutedReplies = + lp_var_t(sid.objectId, PoolIds::EXECUTED_REPLIES, this); + lp_var_t numOfCmdReplies = + lp_var_t(sid.objectId, PoolIds::COMMAND_REPLIES, this); + lp_var_t uartNumOfBytesWritten = + lp_var_t(sid.objectId, PoolIds::UART_BYTES_WRITTEN, this); + lp_var_t uartNumOfBytesRead = + lp_var_t(sid.objectId, PoolIds::UART_BYTES_READ, this); + lp_var_t uartNumOfParityErrors = + lp_var_t(sid.objectId, PoolIds::UART_PARITY_ERRORS, this); + lp_var_t uartNumOfNoiseErrors = + lp_var_t(sid.objectId, PoolIds::UART_NOISE_ERRORS, this); + lp_var_t uartNumOfFrameErrors = + lp_var_t(sid.objectId, PoolIds::UART_FRAME_ERRORS, this); + lp_var_t uartNumOfRegisterOverrunErrors = + lp_var_t(sid.objectId, PoolIds::UART_REG_OVERRUN_ERRORS, this); + lp_var_t uartTotalNumOfErrors = + lp_var_t(sid.objectId, PoolIds::UART_TOTAL_ERRORS, this); + lp_var_t spiNumOfBytesWritten = + lp_var_t(sid.objectId, PoolIds::SPI_BYTES_WRITTEN, this); + lp_var_t spiNumOfBytesRead = + lp_var_t(sid.objectId, PoolIds::SPI_BYTES_READ, this); + lp_var_t spiNumOfRegisterOverrunErrors = + lp_var_t(sid.objectId, PoolIds::SPI_REG_OVERRUN_ERRORS, this); + lp_var_t spiTotalNumOfErrors = + lp_var_t(sid.objectId, PoolIds::SPI_TOTAL_ERRORS, this); }; -} +} // namespace RwDefinitions #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ - diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 43ce16f2..3b56918a 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -1,101 +1,88 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ - namespace SYRLINKS { - static const DeviceCommandId_t NONE = 0x0; - static const DeviceCommandId_t RESET_UNIT = 0x01; - /** Reads out all status registers */ - static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; - /** Sets Tx mode to standby */ - static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; - /** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ - static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; - /** Sends out a single carrier wave for testing purpose */ - static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; - static const DeviceCommandId_t ACK_REPLY = 0x06; - static const DeviceCommandId_t READ_TX_STATUS = 0x07; - static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; - static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; - static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; +static const DeviceCommandId_t NONE = 0x0; +static const DeviceCommandId_t RESET_UNIT = 0x01; +/** Reads out all status registers */ +static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; +/** Sets Tx mode to standby */ +static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; +/** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ +static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; +/** Sends out a single carrier wave for testing purpose */ +static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; +static const DeviceCommandId_t ACK_REPLY = 0x06; +static const DeviceCommandId_t READ_TX_STATUS = 0x07; +static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; +static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; +static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; - /** Size of a simple transmission success response */ - static const uint8_t ACK_SIZE = 12; - static const uint8_t SIZE_CRC_AND_TERMINATION = 5; - /** The size of the header with the message identifier and the payload size field */ - static const uint8_t MESSAGE_HEADER_SIZE = 5; - /** Size of reply to an rx status registers request */ - static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49; - static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13; +/** Size of a simple transmission success response */ +static const uint8_t ACK_SIZE = 12; +static const uint8_t SIZE_CRC_AND_TERMINATION = 5; +/** The size of the header with the message identifier and the payload size field */ +static const uint8_t MESSAGE_HEADER_SIZE = 5; +/** Size of reply to an rx status registers request */ +static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49; +static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13; - static const uint8_t RX_DATASET_ID = 0x1; - static const uint8_t TX_DATASET_ID = 0x2; +static const uint8_t RX_DATASET_ID = 0x1; +static const uint8_t TX_DATASET_ID = 0x2; - static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE; - static const size_t MAX_COMMAND_SIZE = 15; +static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE; +static const size_t MAX_COMMAND_SIZE = 15; - static const size_t CRC_FIELD_SIZE = 4; +static const size_t CRC_FIELD_SIZE = 4; - static const uint8_t RX_DATASET_SIZE = 8; - static const uint8_t TX_DATASET_SIZE = 3; +static const uint8_t RX_DATASET_SIZE = 8; +static const uint8_t TX_DATASET_SIZE = 3; - enum SyrlinksPoolIds: lp_id_t { - RX_STATUS, - RX_SENSITIVITY, - RX_FREQUENCY_SHIFT, - RX_IQ_POWER, - RX_AGC_VALUE, - RX_DEMOD_EB, - RX_DEMOD_N0, - RX_DATA_RATE, - TX_STATUS, - TX_CONV_DIFF, - TX_CONV_FILTER, - TX_WAVEFORM, - TX_PCM_INDEX, - TX_AGC_VALUE, - }; - -class RxDataset: public StaticLocalDataSet { -public: - - RxDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, RX_DATASET_ID) { - } - - RxDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) { - } - - lp_var_t rxStatus = lp_var_t(sid.objectId, RX_STATUS, this); - lp_var_t rxSensitivity = lp_var_t(sid.objectId, RX_SENSITIVITY, this); - lp_var_t rxFrequencyShift = lp_var_t(sid.objectId, RX_FREQUENCY_SHIFT, this); - lp_var_t rxIqPower = lp_var_t(sid.objectId, RX_IQ_POWER, this); - lp_var_t rxAgcValue = lp_var_t(sid.objectId, RX_AGC_VALUE, this); - lp_var_t rxDemodEb = lp_var_t(sid.objectId, RX_DEMOD_EB, this); - lp_var_t rxDemodN0 = lp_var_t(sid.objectId, RX_DEMOD_N0, this); - lp_var_t rxDataRate = lp_var_t(sid.objectId, RX_DATA_RATE, this); +enum SyrlinksPoolIds : lp_id_t { + RX_STATUS, + RX_SENSITIVITY, + RX_FREQUENCY_SHIFT, + RX_IQ_POWER, + RX_AGC_VALUE, + RX_DEMOD_EB, + RX_DEMOD_N0, + RX_DATA_RATE, + TX_STATUS, + TX_CONV_DIFF, + TX_CONV_FILTER, + TX_WAVEFORM, + TX_PCM_INDEX, + TX_AGC_VALUE, }; +class RxDataset : public StaticLocalDataSet { + public: + RxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, RX_DATASET_ID) {} -class TxDataset: public StaticLocalDataSet { -public: + RxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RX_DATASET_ID)) {} - TxDataset(HasLocalDataPoolIF* owner) : - StaticLocalDataSet(owner, TX_DATASET_ID) { - } - - TxDataset(object_id_t objectId) : - StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) { - } - - lp_var_t txStatus = lp_var_t(sid.objectId, TX_STATUS, this); - lp_var_t txWaveform = lp_var_t(sid.objectId, TX_WAVEFORM, this); - lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); + lp_var_t rxStatus = lp_var_t(sid.objectId, RX_STATUS, this); + lp_var_t rxSensitivity = lp_var_t(sid.objectId, RX_SENSITIVITY, this); + lp_var_t rxFrequencyShift = lp_var_t(sid.objectId, RX_FREQUENCY_SHIFT, this); + lp_var_t rxIqPower = lp_var_t(sid.objectId, RX_IQ_POWER, this); + lp_var_t rxAgcValue = lp_var_t(sid.objectId, RX_AGC_VALUE, this); + lp_var_t rxDemodEb = lp_var_t(sid.objectId, RX_DEMOD_EB, this); + lp_var_t rxDemodN0 = lp_var_t(sid.objectId, RX_DEMOD_N0, this); + lp_var_t rxDataRate = lp_var_t(sid.objectId, RX_DATA_RATE, this); }; -} +class TxDataset : public StaticLocalDataSet { + public: + TxDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TX_DATASET_ID) {} + TxDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TX_DATASET_ID)) {} + + lp_var_t txStatus = lp_var_t(sid.objectId, TX_STATUS, this); + lp_var_t txWaveform = lp_var_t(sid.objectId, TX_WAVEFORM, this); + lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); +}; + +} // namespace SYRLINKS #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/Tmp1075Definitions.h b/mission/devices/devicedefinitions/Tmp1075Definitions.h index 603260ac..3f48508c 100644 --- a/mission/devices/devicedefinitions/Tmp1075Definitions.h +++ b/mission/devices/devicedefinitions/Tmp1075Definitions.h @@ -2,46 +2,35 @@ #define MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_ namespace TMP1075 { - static const uint8_t TEMP_REG_ADDR = 0x0; - static const uint8_t CFGR_ADDR = 0x1; +static const uint8_t TEMP_REG_ADDR = 0x0; +static const uint8_t CFGR_ADDR = 0x1; - /* Writing this information to the configuration register sets the tmp1075 - * to shutdown mode and starts a single temperature conversion */ - static const uint16_t ONE_SHOT_MODE = 0x8100; +/* Writing this information to the configuration register sets the tmp1075 + * to shutdown mode and starts a single temperature conversion */ +static const uint16_t ONE_SHOT_MODE = 0x8100; - static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending - static const DeviceCommandId_t GET_TEMP = 0x1; - static const DeviceCommandId_t START_ADC_CONVERSION = 0x2; +static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending +static const DeviceCommandId_t GET_TEMP = 0x1; +static const DeviceCommandId_t START_ADC_CONVERSION = 0x2; - static const uint8_t GET_TEMP_REPLY_SIZE = 2; - static const uint8_t CFGR_CMD_SIZE = 3; - static const uint8_t POINTER_REG_SIZE = 1; +static const uint8_t GET_TEMP_REPLY_SIZE = 2; +static const uint8_t CFGR_CMD_SIZE = 3; +static const uint8_t POINTER_REG_SIZE = 1; - static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP; +static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP; - static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; +static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; - enum Tmp1075PoolIds: lp_id_t { - TEMPERATURE_C_TMP1075_1, - TEMPERATURE_C_TMP1075_2 - }; +enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075_1, TEMPERATURE_C_TMP1075_2 }; -class Tmp1075Dataset: - public StaticLocalDataSet { -public: +class Tmp1075Dataset : public StaticLocalDataSet { + public: + Tmp1075Dataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {} - Tmp1075Dataset(HasLocalDataPoolIF* owner): - StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) { - } + Tmp1075Dataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) {} - Tmp1075Dataset(object_id_t objectId): - StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) { - } - - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, - TEMPERATURE_C_TMP1075_1, this); + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C_TMP1075_1, this); }; -} - +} // namespace TMP1075 #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_TMP1075DEFINITIONS_H_ */ diff --git a/mission/memory/NVMParameterBase.cpp b/mission/memory/NVMParameterBase.cpp index e7b8e8a6..0802a392 100644 --- a/mission/memory/NVMParameterBase.cpp +++ b/mission/memory/NVMParameterBase.cpp @@ -1,50 +1,44 @@ #include "NVMParameterBase.h" -#include "fsfw/memory/HasFileSystemIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include -NVMParameterBase::NVMParameterBase(std::string fullName): fullName(fullName) { -} +#include "fsfw/memory/HasFileSystemIF.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +NVMParameterBase::NVMParameterBase(std::string fullName) : fullName(fullName) {} ReturnValue_t NVMParameterBase::readJsonFile() { - if(std::filesystem::exists(fullName)) { - // Read JSON file content into object - std::ifstream i(fullName); - i >> json; - return HasReturnvaluesIF::RETURN_OK; - } - return HasFileSystemIF::FILE_DOES_NOT_EXIST; + if (std::filesystem::exists(fullName)) { + // Read JSON file content into object + std::ifstream i(fullName); + i >> json; + return HasReturnvaluesIF::RETURN_OK; + } + return HasFileSystemIF::FILE_DOES_NOT_EXIST; } ReturnValue_t NVMParameterBase::writeJsonFile() { - std::ofstream o(fullName); - o << std::setw(4) << json; - return HasReturnvaluesIF::RETURN_OK; + std::ofstream o(fullName); + o << std::setw(4) << json; + return HasReturnvaluesIF::RETURN_OK; } -void NVMParameterBase::setFullName(std::string fullName) { - this->fullName = fullName; -} +void NVMParameterBase::setFullName(std::string fullName) { this->fullName = fullName; } -std::string NVMParameterBase::getFullName() const { - return fullName; -} +std::string NVMParameterBase::getFullName() const { return fullName; } -bool NVMParameterBase::getJsonFileExists() { - return std::filesystem::exists(fullName); -} +bool NVMParameterBase::getJsonFileExists() { return std::filesystem::exists(fullName); } void NVMParameterBase::printKeys() const { - sif::info << "Printing keys for JSON file " << fullName << std::endl; - for(const auto& key: keys) { - sif::info << key << std::endl; - } + sif::info << "Printing keys for JSON file " << fullName << std::endl; + for (const auto& key : keys) { + sif::info << key << std::endl; + } } void NVMParameterBase::print() const { - sif::info << "Printing JSON file " << fullName << std::endl; - for(const auto& key: keys) { - sif::info << key << ": " << json[key] << std::endl; - } + sif::info << "Printing JSON file " << fullName << std::endl; + for (const auto& key : keys) { + sif::info << key << ": " << json[key] << std::endl; + } } diff --git a/mission/memory/NVMParameterBase.h b/mission/memory/NVMParameterBase.h index f41f9e63..aafbf8cc 100644 --- a/mission/memory/NVMParameterBase.h +++ b/mission/memory/NVMParameterBase.h @@ -1,79 +1,78 @@ #ifndef BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ #define BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" - +#include #include #include -#include + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" class NVMParameterBase : public HasReturnvaluesIF { -public: - virtual~ NVMParameterBase() {} + public: + virtual ~NVMParameterBase() {} - NVMParameterBase(std::string fullName); + NVMParameterBase(std::string fullName); - bool getJsonFileExists(); + bool getJsonFileExists(); - /** - * Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if - * file does not exist yet. - * @return - */ - virtual ReturnValue_t readJsonFile(); + /** + * Returns RETURN_OK on successfull read and HasFileSystemIF::FILE_DOES_NOT_EXIST if + * file does not exist yet. + * @return + */ + virtual ReturnValue_t readJsonFile(); - virtual ReturnValue_t writeJsonFile(); + virtual ReturnValue_t writeJsonFile(); - void setFullName(std::string fullName); - std::string getFullName() const; + void setFullName(std::string fullName); + std::string getFullName() const; - template - ReturnValue_t insertValue(std::string key, T value); + template + ReturnValue_t insertValue(std::string key, T value); - template - ReturnValue_t setValue(std::string key, T value); + template + ReturnValue_t setValue(std::string key, T value); - template - ReturnValue_t getValue(std::string key, T* value) const; + template + ReturnValue_t getValue(std::string key, T* value) const; - void printKeys() const; - void print() const; + void printKeys() const; + void print() const; -private: + private: + static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE; - static const uint8_t INTERFACE_ID = CLASS_ID::NVM_PARAM_BASE; + //! [EXPORT] : [COMMENT] Specified key does not exist in json file + static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0); - //! [EXPORT] : [COMMENT] Specified key does not exist in json file - static const ReturnValue_t KEY_NOT_EXISTS = MAKE_RETURN_CODE(0xA0); - - nlohmann::json json; - std::vector keys; - std::string fullName; + nlohmann::json json; + std::vector keys; + std::string fullName; }; -template +template inline ReturnValue_t NVMParameterBase::insertValue(std::string key, T value) { - // Check whether key already exists. If it does not, insert it - if (std::find(keys.begin(), keys.end(), key) == keys.end()) { - keys.push_back(key); - } - json[key] = value; - return HasReturnvaluesIF::RETURN_OK; + // Check whether key already exists. If it does not, insert it + if (std::find(keys.begin(), keys.end(), key) == keys.end()) { + keys.push_back(key); + } + json[key] = value; + return HasReturnvaluesIF::RETURN_OK; } -template +template inline ReturnValue_t NVMParameterBase::setValue(std::string key, T value) { - json[key] = value; - return HasReturnvaluesIF::RETURN_OK; + json[key] = value; + return HasReturnvaluesIF::RETURN_OK; } -template +template inline ReturnValue_t NVMParameterBase::getValue(std::string key, T* value) const { - if (!json.contains(key)) { - return KEY_NOT_EXISTS; - } - *value = json[key]; - return RETURN_OK; + if (!json.contains(key)) { + return KEY_NOT_EXISTS; + } + *value = json[key]; + return RETURN_OK; } #endif /* BSP_Q7S_CORE_NVMPARAMS_NVMPARAMIF_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 524fe4b8..ba34d273 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -1,303 +1,301 @@ -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/ipc/QueueFactory.h" -#include "fsfw/events/EventManagerIF.h" +#include "CCSDSHandler.h" #include -#include "CCSDSHandler.h" +#include "fsfw/events/EventManagerIF.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData) : - SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), parameterHelper(this), actionHelper( - this, nullptr), txRateSetterIF(txRateSetterIF), gpioIF(gpioIF), enTxClock( - enTxClock), enTxData(enTxData) { - commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); - eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, + gpioId_t enTxData) + : SystemObject(objectId), + ptmeId(ptmeId), + tcDestination(tcDestination), + parameterHelper(this), + actionHelper(this, nullptr), + txRateSetterIF(txRateSetterIF), + gpioIF(gpioIF), + enTxClock(enTxClock), + enTxData(enTxData) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); + eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 2); } -CCSDSHandler::~CCSDSHandler() { -} +CCSDSHandler::~CCSDSHandler() {} ReturnValue_t CCSDSHandler::performOperation(uint8_t operationCode) { - checkEvents(); - readCommandQueue(); - handleTelemetry(); - handleTelecommands(); - checkTxTimer(); - return RETURN_OK; + checkEvents(); + readCommandQueue(); + handleTelemetry(); + handleTelecommands(); + checkTxTimer(); + return RETURN_OK; } void CCSDSHandler::handleTelemetry() { - VirtualChannelMapIter iter; - for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - iter->second->performOperation(); - } + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->performOperation(); + } } -void CCSDSHandler::handleTelecommands() { - -} +void CCSDSHandler::handleTelecommands() {} ReturnValue_t CCSDSHandler::initialize() { - ReturnValue_t result = RETURN_OK; - PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); - if (ptme == nullptr) { - sif::warning << "Invalid PTME object" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + ReturnValue_t result = RETURN_OK; + PtmeIF* ptme = ObjectManager::instance()->get(ptmeId); + if (ptme == nullptr) { + sif::warning << "Invalid PTME object" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - AcceptsTelecommandsIF* tcDistributor = - ObjectManager::instance()->get(tcDestination); - if (tcDistributor == nullptr) { + AcceptsTelecommandsIF* tcDistributor = + ObjectManager::instance()->get(tcDestination); + if (tcDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; + sif::error << "CCSDSHandler::initialize: Invalid TC Distributor object" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tcDistributorQueueId = tcDistributor->getRequestQueue(); + tcDistributorQueueId = tcDistributor->getRequestQueue(); - result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + result = parameterHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } - result = actionHelper.initialize(commandQueue); + result = actionHelper.initialize(commandQueue); + if (result != RETURN_OK) { + return result; + } + + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + result = iter->second->initialize(); if (result != RETURN_OK) { - return result; + return result; } + iter->second->setPtmeObject(ptme); + } - VirtualChannelMapIter iter; - for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - result = iter->second->initialize(); - if (result != RETURN_OK) { - return result; - } - iter->second->setPtmeObject(ptme); - } - - EventManagerIF* manager = ObjectManager::instance()->get( - objects::EVENT_MANAGER); - if (manager == nullptr) { + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; + sif::error << "CCSDSHandler::initialize: Invalid event manager" << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } - result = manager->registerListener(eventQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->registerListener(eventQueue->getId()); + if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " - "listener" << std::endl; + sif::warning << "CCSDSHandler::initialize: Failed to register CCSDS handler as event " + "listener" + << std::endl; #endif - return ObjectManagerIF::CHILD_INIT_FAILED;; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(PdecHandler::CARRIER_LOCK), - event::getEventId(PdecHandler::BIT_LOCK_PDEC)); - if (result != HasReturnvaluesIF::RETURN_OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + ; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(PdecHandler::CARRIER_LOCK), + event::getEventId(PdecHandler::BIT_LOCK_PDEC)); + if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " - "handler" << std::endl; + sif::error << "CCSDSHandler::initialize: Failed to subscribe to events from PDEC " + "handler" + << std::endl; #endif - return result; - } - return result; + return result; + } + return result; } void CCSDSHandler::readCommandQueue(void) { - CommandMessage commandMessage; - ReturnValue_t result = RETURN_FAILED; + CommandMessage commandMessage; + ReturnValue_t result = RETURN_FAILED; - result = commandQueue->receiveMessage(&commandMessage); + result = commandQueue->receiveMessage(&commandMessage); + if (result == RETURN_OK) { + result = parameterHelper.handleParameterMessage(&commandMessage); if (result == RETURN_OK) { - result = parameterHelper.handleParameterMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - result = actionHelper.handleActionMessage(&commandMessage); - if (result == RETURN_OK) { - return; - } - CommandMessage reply; - reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, - commandMessage.getCommand()); - commandQueue->reply(&reply); - return; + return; } + result = actionHelper.handleActionMessage(&commandMessage); + if (result == RETURN_OK) { + return; + } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + commandQueue->reply(&reply); + return; + } } -MessageQueueId_t CCSDSHandler::getCommandQueue() const { - return commandQueue->getId(); -} +MessageQueueId_t CCSDSHandler::getCommandQueue() const { return commandQueue->getId(); } void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) { - if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; - return; - } + if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl; + return; + } - if (virtualChannel == nullptr) { - sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" << std::endl; - return; - } + if (virtualChannel == nullptr) { + sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel interface" + << std::endl; + return; + } - auto status = virtualChannelMap.emplace(vcId, virtualChannel); - if (status.second == false) { - sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " - "virtual channel map" << std::endl; - return; - } + auto status = virtualChannelMap.emplace(vcId, virtualChannel); + if (status.second == false) { + sif::warning << "CCSDSHandler::addVirtualChannel: Failed to add virtual channel to " + "virtual channel map" + << std::endl; + return; + } } MessageQueueId_t CCSDSHandler::getReportReceptionQueue(uint8_t virtualChannel) { - if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { - VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); - if (iter != virtualChannelMap.end()) { - return iter->second->getReportReceptionQueue(); - } - else { - sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " - << static_cast(virtualChannel) << " not in virtual channel map" - << std::endl; - return MessageQueueIF::NO_QUEUE; - } - } else { - sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; - - } - return MessageQueueIF::NO_QUEUE; + if (virtualChannel < common::NUMBER_OF_VIRTUAL_CHANNELS) { + VirtualChannelMapIter iter = virtualChannelMap.find(virtualChannel); + if (iter != virtualChannelMap.end()) { + return iter->second->getReportReceptionQueue(); + } else { + sif::warning << "CCSDSHandler::getReportReceptionQueue: Virtual channel with ID " + << static_cast(virtualChannel) << " not in virtual channel map" + << std::endl; + return MessageQueueIF::NO_QUEUE; + } + } else { + sif::debug << "CCSDSHandler::getReportReceptionQueue: Invalid virtual channel requested"; + } + return MessageQueueIF::NO_QUEUE; } ReturnValue_t CCSDSHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, - uint16_t startAtIndex) { - return RETURN_OK; + ParameterWrapper* parameterWrapper, + const ParameterWrapper* newValues, uint16_t startAtIndex) { + return RETURN_OK; } -uint16_t CCSDSHandler::getIdentifier() { - return 0; -} +uint16_t CCSDSHandler::getIdentifier() { return 0; } MessageQueueId_t CCSDSHandler::getRequestQueue() { - // Forward packets directly to TC distributor - return tcDistributorQueueId; + // Forward packets directly to TC distributor + return tcDistributorQueueId; } -ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, - MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - - switch(actionId) { +ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + switch (actionId) { case SET_LOW_RATE: { - txRateSetterIF->setRate(BitRates::RATE_400KHZ); - return EXECUTION_FINISHED; + txRateSetterIF->setRate(BitRates::RATE_400KHZ); + return EXECUTION_FINISHED; } case SET_HIGH_RATE: { - txRateSetterIF->setRate(BitRates::RATE_2000KHZ); - return EXECUTION_FINISHED; + txRateSetterIF->setRate(BitRates::RATE_2000KHZ); + return EXECUTION_FINISHED; } case EN_TRANSMITTER: { - enableTransmit(); - return EXECUTION_FINISHED; + enableTransmit(); + return EXECUTION_FINISHED; } case DIS_TRANSMITTER: { - disableTransmit(); - return EXECUTION_FINISHED; + disableTransmit(); + return EXECUTION_FINISHED; } default: - return COMMAND_NOT_IMPLEMENTED; - } + return COMMAND_NOT_IMPLEMENTED; + } } void CCSDSHandler::checkEvents() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == RETURN_OK; result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEvent(&event); + break; + default: + sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; } + } } - void CCSDSHandler::handleEvent(EventMessage* eventMessage) { - Event event = eventMessage->getEvent(); - switch(event){ + Event event = eventMessage->getEvent(); + switch (event) { case PdecHandler::BIT_LOCK_PDEC: { - handleBitLockEvent(); - break; + handleBitLockEvent(); + break; } case PdecHandler::CARRIER_LOCK: { - handleCarrierLockEvent(); - break; + handleCarrierLockEvent(); + break; } default: - sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" - << std::endl; - break; - } + sif::debug << "CCSDSHandler::handleEvent: Did not subscribe to this event" << std::endl; + break; + } } void CCSDSHandler::handleBitLockEvent() { - if(transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } - enableTransmit(); + if (transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + enableTransmit(); } void CCSDSHandler::handleCarrierLockEvent() { - if (!enableTxWhenCarrierLock) { - return; - } - enableTransmit(); + if (!enableTxWhenCarrierLock) { + return; + } + enableTransmit(); } void CCSDSHandler::forwardLinkstate() { - VirtualChannelMapIter iter; - for(iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { - iter->second->setLinkState(linkState); - } + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + iter->second->setLinkState(linkState); + } } void CCSDSHandler::enableTransmit() { - if(transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } - transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); + if (transmitterCountdown.isBusy()) { + // Transmitter already enabled + return; + } + transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT); #if BOARD_TE0720 == 0 - gpioIF->pullHigh(enTxClock); - gpioIF->pullHigh(enTxData); + gpioIF->pullHigh(enTxClock); + gpioIF->pullHigh(enTxData); #endif /* BOARD_TE0720 == 0 */ - linkState = UP; - // Set link state of all virtual channels to link up - forwardLinkstate(); + linkState = UP; + // Set link state of all virtual channels to link up + forwardLinkstate(); } void CCSDSHandler::checkTxTimer() { - if(linkState == DOWN) { - return; - } - if (transmitterCountdown.hasTimedOut()) { - disableTransmit(); - } + if (linkState == DOWN) { + return; + } + if (transmitterCountdown.hasTimedOut()) { + disableTransmit(); + } } void CCSDSHandler::disableTransmit() { #if BOARD_TE0720 == 0 - gpioIF->pullLow(enTxClock); - gpioIF->pullLow(enTxData); + gpioIF->pullLow(enTxClock); + gpioIF->pullLow(enTxData); #endif /* BOARD_TE0720 == 0 */ - linkState = DOWN; - forwardLinkstate(); - transmitterCountdown.setTimeout(0); + linkState = DOWN; + forwardLinkstate(); + transmitterCountdown.setTimeout(0); } diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 6fb6168b..8203b807 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -1,22 +1,23 @@ #ifndef CCSDSHANDLER_H_ #define CCSDSHANDLER_H_ +#include + #include "OBSWConfig.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/parameters/ParameterHelper.h" +#include "VirtualChannel.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" -#include "fsfw/timemanager/Countdown.h" #include "fsfw/events/EventMessage.h" -#include "linux/obc/TxRateSetterIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/parameters/ParameterHelper.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/timemanager/Countdown.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw_hal/common/gpio/GpioIF.h" -#include "VirtualChannel.h" -#include +#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "linux/obc/TxRateSetterIF.h" /** * @brief This class handles the data exchange with the CCSDS IP cores implemented in the @@ -24,145 +25,144 @@ * * @author J. Meier */ -class CCSDSHandler: public SystemObject, - public ExecutableObjectIF, - public AcceptsTelemetryIF, - public AcceptsTelecommandsIF, - public HasReturnvaluesIF, - public ReceivesParameterMessagesIF, - public HasActionsIF { -public: +class CCSDSHandler : public SystemObject, + public ExecutableObjectIF, + public AcceptsTelemetryIF, + public AcceptsTelecommandsIF, + public HasReturnvaluesIF, + public ReceivesParameterMessagesIF, + public HasActionsIF { + public: + using VcId_t = uint8_t; - using VcId_t = uint8_t; + /** + * @brief Constructor + * + * @param objectId Object ID of the CCSDS handler + * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. + * @param tcDestination Object ID of object handling received TC space packets + * @param txRateSetter Object providing the functionality to switch the input bitrate of + * the S-Band transceiver. + * @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips. + * @param enTxClock GPIO ID of RS485 tx clock enable + * @param enTxData GPIO ID of RS485 tx data enable + */ + CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, + TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, + gpioId_t enTxData); - /** - * @brief Constructor - * - * @param objectId Object ID of the CCSDS handler - * @param ptmeId Object ID of the PTME object providing access to the PTME IP Core. - * @param tcDestination Object ID of object handling received TC space packets - * @param txRateSetter Object providing the functionality to switch the input bitrate of - * the S-Band transceiver. - * @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips. - * @param enTxClock GPIO ID of RS485 tx clock enable - * @param enTxData GPIO ID of RS485 tx data enable - */ - CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - TxRateSetterIF* txRateSetterIF, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData); + ~CCSDSHandler(); - ~CCSDSHandler(); + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t initialize(); + MessageQueueId_t getCommandQueue() const; - ReturnValue_t performOperation(uint8_t operationCode = 0) override; - ReturnValue_t initialize(); - MessageQueueId_t getCommandQueue() const; + /** + * @brief Function to add a virtual channel + * + * @param virtualChannelId ID of the virtual channel to add + * @param virtualChannel Pointer to virtual channel object + */ + void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); - /** - * @brief Function to add a virtual channel - * - * @param virtualChannelId ID of the virtual channel to add - * @param virtualChannel Pointer to virtual channel object - */ - void addVirtualChannel(VcId_t virtualChannelId, VirtualChannel* virtualChannel); + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); + ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, + uint16_t startAtIndex); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0); - ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, - uint16_t startAtIndex); + uint16_t getIdentifier() override; + MessageQueueId_t getRequestQueue() override; - uint16_t getIdentifier() override; - MessageQueueId_t getRequestQueue() override; + virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size); + private: + static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER; -private: + static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER; + static const ActionId_t SET_LOW_RATE = 0; + static const ActionId_t SET_HIGH_RATE = 1; + static const ActionId_t EN_TRANSMITTER = 2; + static const ActionId_t DIS_TRANSMITTER = 3; - static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE; - - static const ActionId_t SET_LOW_RATE = 0; - static const ActionId_t SET_HIGH_RATE = 1; - static const ActionId_t EN_TRANSMITTER = 2; - static const ActionId_t DIS_TRANSMITTER = 3; - - //! [EXPORT] : [COMMENT] Received action message with unknown action id - static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Received action message with unknown action id + static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); #if TMTC_TEST_SETUP == 0 - // syrlinks must not be transmitting more than 15 minutes (according to datasheet) - static const uint32_t TRANSMITTER_TIMEOUT = 900000; //900000 ms = 15 min + // syrlinks must not be transmitting more than 15 minutes (according to datasheet) + static const uint32_t TRANSMITTER_TIMEOUT = 900000; // 900000 ms = 15 min #else - // Set to high value when not sending via syrlinks - static const uint32_t TRANSMITTER_TIMEOUT = 86400000; // 1 day + // Set to high value when not sending via syrlinks + static const uint32_t TRANSMITTER_TIMEOUT = 86400000; // 1 day #endif /* TMTC_TEST_SETUP == 0 */ - static const bool UP = true; - static const bool DOWN = false; + static const bool UP = true; + static const bool DOWN = false; - using VirtualChannelMap = std::unordered_map; - using VirtualChannelMapIter = VirtualChannelMap::iterator; + using VirtualChannelMap = std::unordered_map; + using VirtualChannelMapIter = VirtualChannelMap::iterator; - VirtualChannelMap virtualChannelMap; + VirtualChannelMap virtualChannelMap; - // Object ID of PTME object - object_id_t ptmeId; + // Object ID of PTME object + object_id_t ptmeId; - object_id_t tcDestination; + object_id_t tcDestination; - MessageQueueIF* commandQueue = nullptr; - MessageQueueIF* eventQueue = nullptr; + MessageQueueIF* commandQueue = nullptr; + MessageQueueIF* eventQueue = nullptr; - ParameterHelper parameterHelper; + ParameterHelper parameterHelper; - ActionHelper actionHelper; + ActionHelper actionHelper; - MessageQueueId_t tcDistributorQueueId; + MessageQueueId_t tcDistributorQueueId; - TxRateSetterIF* txRateSetterIF = nullptr; + TxRateSetterIF* txRateSetterIF = nullptr; - GpioIF* gpioIF = nullptr; - gpioId_t enTxClock = gpio::NO_GPIO; - gpioId_t enTxData = gpio::NO_GPIO; + GpioIF* gpioIF = nullptr; + gpioId_t enTxClock = gpio::NO_GPIO; + gpioId_t enTxData = gpio::NO_GPIO; - // Countdown to disable transmitter after 15 minutes - Countdown transmitterCountdown; + // Countdown to disable transmitter after 15 minutes + Countdown transmitterCountdown; - // When true transmitting is started as soon as carrier lock has been detected - bool enableTxWhenCarrierLock = false; + // When true transmitting is started as soon as carrier lock has been detected + bool enableTxWhenCarrierLock = false; - bool linkState = DOWN; + bool linkState = DOWN; - void readCommandQueue(void); - void handleTelemetry(); - void handleTelecommands(); - void checkEvents(); - void handleEvent(EventMessage* eventMessage); + void readCommandQueue(void); + void handleTelemetry(); + void handleTelecommands(); + void checkEvents(); + void handleEvent(EventMessage* eventMessage); - void handleBitLockEvent(); - void handleCarrierLockEvent(); + void handleBitLockEvent(); + void handleCarrierLockEvent(); - /** - * @brief Forward link state to virtual channels. - */ - void forwardLinkstate(); + /** + * @brief Forward link state to virtual channels. + */ + void forwardLinkstate(); - /** - * @brief Starts transmit timer and enables transmitter. - */ - void enableTransmit(); + /** + * @brief Starts transmit timer and enables transmitter. + */ + void enableTransmit(); - /** - * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case - * timer has expired. - */ - void checkTxTimer(); + /** + * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case + * timer has expired. + */ + void checkTxTimer(); - /** - * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the - * RS485 transceiver chips to high. - */ - void disableTransmit(); + /** + * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the + * RS485 transceiver chips to high. + */ + void disableTransmit(); }; #endif /* CCSDSHANDLER_H_ */ diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 0273f5ce..5b9387fd 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -1,69 +1,65 @@ -#include "CCSDSHandler.h" #include "VirtualChannel.h" + +#include "CCSDSHandler.h" #include "OBSWConfig.h" - -#include "fsfw/serviceinterface/ServiceInterfaceStream.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/tmtcservices/TmTcMessage.h" - -VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : - vcId(vcId) { - tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); +VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth) : vcId(vcId) { + tmQueue = QueueFactory::instance()->createMessageQueue(tmQueueDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE); } ReturnValue_t VirtualChannel::initialize() { - tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { - sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl; + return RETURN_FAILED; + } + return RETURN_OK; } ReturnValue_t VirtualChannel::performOperation() { - ReturnValue_t result = RETURN_OK; - TmTcMessage message; + ReturnValue_t result = RETURN_OK; + TmTcMessage message; - while(tmQueue->receiveMessage(&message) == RETURN_OK) { - store_address_t storeId = message.getStorageId(); - const uint8_t* data = nullptr; - size_t size = 0; - result = tmStore->getData(storeId, &data, &size); - if (result != RETURN_OK) { - sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" - << std::endl; - tmStore->deleteData(storeId); - return result; - } + while (tmQueue->receiveMessage(&message) == RETURN_OK) { + store_address_t storeId = message.getStorageId(); + const uint8_t* data = nullptr; + size_t size = 0; + result = tmStore->getData(storeId, &data, &size); + if (result != RETURN_OK) { + sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" + << std::endl; + tmStore->deleteData(storeId); + return result; + } - if (linkIsUp) { - result = ptme->writeToVc(vcId, data, size); - } + if (linkIsUp) { + result = ptme->writeToVc(vcId, data, size); + } - tmStore->deleteData(storeId); + tmStore->deleteData(storeId); - if (result != RETURN_OK) { - return result; - } - } - return result; + if (result != RETURN_OK) { + return result; + } + } + return result; } MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue->getId(); + return tmQueue->getId(); } void VirtualChannel::setPtmeObject(PtmeIF* ptme_) { - if (ptme_ == nullptr) { - sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; - return; - } - ptme = ptme_; + if (ptme_ == nullptr) { + sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; + return; + } + ptme = ptme_; } -void VirtualChannel::setLinkState(bool linkIsUp_) { - linkIsUp = linkIsUp_; -} +void VirtualChannel::setLinkState(bool linkIsUp_) { linkIsUp = linkIsUp_; } diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index 213a3421..48cc74a4 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -1,12 +1,13 @@ #ifndef VIRTUALCHANNEL_H_ #define VIRTUALCHANNEL_H_ -#include "OBSWConfig.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include #include +#include "OBSWConfig.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" + class StorageManagerIF; /** @@ -15,42 +16,41 @@ class StorageManagerIF; * * @author J. Meier */ -class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { - public: - /** - * @brief Constructor - * - * @param vcId The virtual channel id assigned to this object - * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects - */ - VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); +class VirtualChannel : public AcceptsTelemetryIF, public HasReturnvaluesIF { + public: + /** + * @brief Constructor + * + * @param vcId The virtual channel id assigned to this object + * @param tmQueueDepth Queue depth of queue receiving telemetry from other objects + */ + VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth); - ReturnValue_t initialize(); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; - ReturnValue_t performOperation(); + ReturnValue_t initialize(); + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + ReturnValue_t performOperation(); - /** - * @brief Sets the PTME object which handles access to the PTME IP Core. - * - * @param ptme Pointer to ptme object - */ - void setPtmeObject(PtmeIF* ptme_); + /** + * @brief Sets the PTME object which handles access to the PTME IP Core. + * + * @param ptme Pointer to ptme object + */ + void setPtmeObject(PtmeIF* ptme_); - /** - * @brief Can be used by the owner to set the link state. Packets will be discarded if link - * to ground station is down. - */ - void setLinkState(bool linkIsUp_); + /** + * @brief Can be used by the owner to set the link state. Packets will be discarded if link + * to ground station is down. + */ + void setLinkState(bool linkIsUp_); -private: + private: + PtmeIF* ptme = nullptr; + MessageQueueIF* tmQueue = nullptr; + uint8_t vcId; - PtmeIF* ptme = nullptr; - MessageQueueIF* tmQueue = nullptr; - uint8_t vcId; + bool linkIsUp = false; - bool linkIsUp = false; - - StorageManagerIF* tmStore = nullptr; + StorageManagerIF* tmStore = nullptr; }; #endif /* VIRTUALCHANNEL_H_ */ diff --git a/mission/utility/InitMission.h b/mission/utility/InitMission.h index b4a83a1e..dc131981 100644 --- a/mission/utility/InitMission.h +++ b/mission/utility/InitMission.h @@ -8,15 +8,15 @@ namespace initmission { void printAddObjectError(const char* name, object_id_t objectId) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x" - << std::hex << std::setfill('0') << std::setw(8) << objectId - << " failed!" << std::dec << std::endl; + sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x" + << std::hex << std::setfill('0') << std::setw(8) << objectId << " failed!" << std::dec + << std::endl; #else - sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n" , - name, objectId); + sif::printError("InitMission::printAddError: Adding object %s with object ID 0x%08x failed!\n", + name, objectId); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ } -} +} // namespace initmission #endif /* MISSION_UTILITY_INITMISSION_H_ */ diff --git a/mission/utility/Timestamp.cpp b/mission/utility/Timestamp.cpp index c0848a59..095bd28c 100644 --- a/mission/utility/Timestamp.cpp +++ b/mission/utility/Timestamp.cpp @@ -1,28 +1,22 @@ #include "Timestamp.h" + #include "fsfw/serviceinterface/ServiceInterfaceStream.h" Timestamp::Timestamp() { - ReturnValue_t result = Clock::getDateAndTime(&time); - if (result != RETURN_OK) { - sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl; - } + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "Timestamp::Timestamp: Failed to get time" << std::endl; + } } -Timestamp::~Timestamp() { -} +Timestamp::~Timestamp() {} std::string Timestamp::str() { - timestamp << std::to_string(time.year) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.month) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.day) << "--" - << std::setw(2) << std::setfill('0') - << std::to_string(time.hour) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.minute) << "-" - << std::setw(2) << std::setfill('0') - << std::to_string(time.second) << "--"; - return timestamp.str(); + timestamp << std::to_string(time.year) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.month) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.day) << "--" << std::setw(2) << std::setfill('0') + << std::to_string(time.hour) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.minute) << "-" << std::setw(2) << std::setfill('0') + << std::to_string(time.second) << "--"; + return timestamp.str(); } - diff --git a/mission/utility/Timestamp.h b/mission/utility/Timestamp.h index 7146de53..4f783437 100644 --- a/mission/utility/Timestamp.h +++ b/mission/utility/Timestamp.h @@ -1,11 +1,12 @@ #ifndef MISSION_UTILITY_TIMESTAMP_H_ #define MISSION_UTILITY_TIMESTAMP_H_ -#include -#include #include -#include "fsfw/timemanager/Clock.h" +#include +#include + #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/timemanager/Clock.h" /** * @brief This class generates timestamps for files. @@ -13,18 +14,18 @@ * @author J. Meier */ class Timestamp : public HasReturnvaluesIF { -public: - Timestamp(); - virtual ~Timestamp(); + public: + Timestamp(); + virtual ~Timestamp(); - /** - * @brief Returns the timestamp string - */ - std::string str(); + /** + * @brief Returns the timestamp string + */ + std::string str(); -private: - std::stringstream timestamp; - Clock::TimeOfDay_t time; + private: + std::stringstream timestamp; + Clock::TimeOfDay_t time; }; #endif /* MISSION_UTILITY_TIMESTAMP_H_ */ diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index 4b9eebdf..5577f5fa 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -1,122 +1,118 @@ -#include "OBSWConfig.h" #include -#include #include #include +#include #include +#include "OBSWConfig.h" + object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT; object_id_t TmFunnel::storageDestination = objects::NO_OBJECT; -TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth): - SystemObject(objectId), messageDepth(messageDepth) { - tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); - storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); +TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth) + : SystemObject(objectId), messageDepth(messageDepth) { + tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth, + MessageQueueMessage::MAX_MESSAGE_SIZE); + storageQueue = QueueFactory::instance()->createMessageQueue( + messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE); } -TmFunnel::~TmFunnel() { -} +TmFunnel::~TmFunnel() {} MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue->getId(); + return tmQueue->getId(); } ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) { - TmTcMessage currentMessage; - ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); - while(status == HasReturnvaluesIF::RETURN_OK) - { - status = handlePacket(¤tMessage); - if(status != HasReturnvaluesIF::RETURN_OK){ - break; - } - status = tmQueue->receiveMessage(¤tMessage); - } + TmTcMessage currentMessage; + ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); + while (status == HasReturnvaluesIF::RETURN_OK) { + status = handlePacket(¤tMessage); + if (status != HasReturnvaluesIF::RETURN_OK) { + break; + } + status = tmQueue->receiveMessage(¤tMessage); + } - if (status == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_OK; - } - else { - return status; - } + if (status == MessageQueueIF::EMPTY) { + return HasReturnvaluesIF::RETURN_OK; + } else { + return status; + } } ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) { - uint8_t* packetData = nullptr; - size_t size = 0; - ReturnValue_t result = tmStore->modifyData(message->getStorageId(), - &packetData, &size); - if(result != HasReturnvaluesIF::RETURN_OK){ - return result; - } - TmPacketPusC packet(packetData); - packet.setPacketSequenceCount(this->sourceSequenceCount); - sourceSequenceCount++; - sourceSequenceCount = sourceSequenceCount % - SpacePacketBase::LIMIT_SEQUENCE_COUNT; - packet.setErrorControl(); + uint8_t* packetData = nullptr; + size_t size = 0; + ReturnValue_t result = tmStore->modifyData(message->getStorageId(), &packetData, &size); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + TmPacketPusC packet(packetData); + packet.setPacketSequenceCount(this->sourceSequenceCount); + sourceSequenceCount++; + sourceSequenceCount = sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT; + packet.setErrorControl(); - result = tmQueue->sendToDefault(message); - if(result != HasReturnvaluesIF::RETURN_OK){ - tmStore->deleteData(message->getStorageId()); - sif::error << "TmFunnel::handlePacket: Error sending to downlink " - "handler" << std::endl; - return result; - } + result = tmQueue->sendToDefault(message); + if (result != HasReturnvaluesIF::RETURN_OK) { + tmStore->deleteData(message->getStorageId()); + sif::error << "TmFunnel::handlePacket: Error sending to downlink " + "handler" + << std::endl; + return result; + } - if(storageDestination != objects::NO_OBJECT) { - result = storageQueue->sendToDefault(message); - if(result != HasReturnvaluesIF::RETURN_OK){ - tmStore->deleteData(message->getStorageId()); - sif::error << "TmFunnel::handlePacket: Error sending to storage " - "handler" << std::endl; - return result; - } - } - return result; + if (storageDestination != objects::NO_OBJECT) { + result = storageQueue->sendToDefault(message); + if (result != HasReturnvaluesIF::RETURN_OK) { + tmStore->deleteData(message->getStorageId()); + sif::error << "TmFunnel::handlePacket: Error sending to storage " + "handler" + << std::endl; + return result; + } + } + return result; } ReturnValue_t TmFunnel::initialize() { + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + sif::error << "TmFunnel::initialize: TM store not set." << std::endl; + sif::error << "Make sure the tm store is set up properly" + " and implements StorageManagerIF" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } - tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { - sif::error << "TmFunnel::initialize: TM store not set." - << std::endl; - sif::error << "Make sure the tm store is set up properly" - " and implements StorageManagerIF" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - - AcceptsTelemetryIF* tmTarget = - ObjectManager::instance()->get(downlinkDestination); - if(tmTarget == nullptr){ - sif::error << "TmFunnel::initialize: Downlink Destination not set." - << std::endl; - sif::error << "Make sure the downlink destination object is set up " - "properly and implements AcceptsTelemetryIF" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } + AcceptsTelemetryIF* tmTarget = + ObjectManager::instance()->get(downlinkDestination); + if (tmTarget == nullptr) { + sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl; + sif::error << "Make sure the downlink destination object is set up " + "properly and implements AcceptsTelemetryIF" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } #if OBSW_TM_TO_PTME == 1 - // Live TM will be sent via the virtual channel 0 - tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM)); + // Live TM will be sent via the virtual channel 0 + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(config::LIVE_TM)); #else - tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); + tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue()); #endif /* OBSW_TM_TO_PTME == 1 */ - // Storage destination is optional. - if(storageDestination == objects::NO_OBJECT) { - return SystemObject::initialize(); - } + // Storage destination is optional. + if (storageDestination == objects::NO_OBJECT) { + return SystemObject::initialize(); + } - AcceptsTelemetryIF* storageTarget = - ObjectManager::instance()->get(storageDestination); - if(storageTarget != nullptr) { - storageQueue->setDefaultDestination( - storageTarget->getReportReceptionQueue()); - } + AcceptsTelemetryIF* storageTarget = + ObjectManager::instance()->get(storageDestination); + if (storageTarget != nullptr) { + storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue()); + } - return SystemObject::initialize(); + return SystemObject::initialize(); } diff --git a/mission/utility/TmFunnel.h b/mission/utility/TmFunnel.h index b85a09e0..013e0ebc 100644 --- a/mission/utility/TmFunnel.h +++ b/mission/utility/TmFunnel.h @@ -1,13 +1,13 @@ #ifndef MISSION_UTILITY_TMFUNNEL_H_ #define MISSION_UTILITY_TMFUNNEL_H_ +#include #include #include #include -#include #include -namespace Factory{ +namespace Factory { void setStaticFrameworkObjectIds(); } @@ -19,32 +19,30 @@ void setStaticFrameworkObjectIds(); * @ingroup utility * @author J. Meier */ -class TmFunnel: public AcceptsTelemetryIF, - public ExecutableObjectIF, - public SystemObject { - friend void (Factory::setStaticFrameworkObjectIds)(); -public: - TmFunnel(object_id_t objectId, uint32_t messageDepth = 20); - virtual ~TmFunnel(); +class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject { + friend void(Factory::setStaticFrameworkObjectIds)(); - virtual MessageQueueId_t getReportReceptionQueue( - uint8_t virtualChannel = 0) override; - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; - virtual ReturnValue_t initialize() override; + public: + TmFunnel(object_id_t objectId, uint32_t messageDepth = 20); + virtual ~TmFunnel(); -protected: - static object_id_t downlinkDestination; - static object_id_t storageDestination; + virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + virtual ReturnValue_t initialize() override; -private: - uint16_t sourceSequenceCount = 0; - MessageQueueIF* tmQueue = nullptr; - MessageQueueIF* storageQueue = nullptr; + protected: + static object_id_t downlinkDestination; + static object_id_t storageDestination; - StorageManagerIF* tmStore = nullptr; - uint32_t messageDepth = 0; + private: + uint16_t sourceSequenceCount = 0; + MessageQueueIF* tmQueue = nullptr; + MessageQueueIF* storageQueue = nullptr; - ReturnValue_t handlePacket(TmTcMessage* message); + StorageManagerIF* tmStore = nullptr; + uint32_t messageDepth = 0; + + ReturnValue_t handlePacket(TmTcMessage* message); }; #endif /* MISSION_UTILITY_TMFUNNEL_H_ */ diff --git a/test/DummyParameter.h b/test/DummyParameter.h index b8da7275..410f0958 100644 --- a/test/DummyParameter.h +++ b/test/DummyParameter.h @@ -1,26 +1,24 @@ #ifndef BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ #define BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ -#include "mission/memory/NVMParameterBase.h" +#include #include -#include +#include "mission/memory/NVMParameterBase.h" -class DummyParameter: public NVMParameterBase { -public: - static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1"; - static constexpr char DUMMY_KEY_PARAM_2[] = "dummy2"; +class DummyParameter : public NVMParameterBase { + public: + static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1"; + static constexpr char DUMMY_KEY_PARAM_2[] = "dummy2"; - DummyParameter(std::string mountPrefix, std::string jsonFileName): - NVMParameterBase(mountPrefix + "/conf/" + jsonFileName), - mountPrefix(mountPrefix) { - insertValue(DUMMY_KEY_PARAM_1, 1); - insertValue(DUMMY_KEY_PARAM_2, "blablub"); - } + DummyParameter(std::string mountPrefix, std::string jsonFileName) + : NVMParameterBase(mountPrefix + "/conf/" + jsonFileName), mountPrefix(mountPrefix) { + insertValue(DUMMY_KEY_PARAM_1, 1); + insertValue(DUMMY_KEY_PARAM_2, "blablub"); + } -private: - std::string mountPrefix; + private: + std::string mountPrefix; }; - #endif /* BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ */ diff --git a/test/testtasks/PusTcInjector.cpp b/test/testtasks/PusTcInjector.cpp index 90f2ac75..82b1cb1c 100644 --- a/test/testtasks/PusTcInjector.cpp +++ b/test/testtasks/PusTcInjector.cpp @@ -1,29 +1,29 @@ -#include - +#include +#include #include +#include +#include #include #include -#include -#include -#include -#include +#include -PusTcInjector::PusTcInjector(object_id_t objectId, object_id_t destination, - object_id_t tcStore, uint16_t defaultApid): SystemObject(objectId), - defaultApid(defaultApid), destination(destination), tcStoreId(tcStore) { -} +PusTcInjector::PusTcInjector(object_id_t objectId, object_id_t destination, object_id_t tcStore, + uint16_t defaultApid) + : SystemObject(objectId), + defaultApid(defaultApid), + destination(destination), + tcStoreId(tcStore) {} -PusTcInjector::~PusTcInjector() { -} +PusTcInjector::~PusTcInjector() {} -//ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, +// ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, // uint8_t subservice,const uint8_t* appData, size_t appDataLen) { // return injectPusTelecommand(service, subservice, defaultApid, appData, // appDataLen); -//} +// } // TODO: ACK flags -//ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, +// ReturnValue_t PusTcInjector::injectPusTelecommand(uint8_t service, // uint8_t subservice,uint16_t apid, const uint8_t* appData, // size_t appDataLen) { // // Prepare TC packet. Store into TC store immediately. @@ -44,24 +44,22 @@ PusTcInjector::~PusTcInjector() { //} ReturnValue_t PusTcInjector::initialize() { - // Prepare message queue which is used to send telecommands. - injectionQueue = QueueFactory::instance()-> - createMessageQueue(INJECTION_QUEUE_DEPTH); - AcceptsTelecommandsIF* targetQueue = ObjectManager::instance()-> - get(destination); - if(targetQueue == nullptr) { - sif::error << "PusTcInjector: CCSDS distributor not initialized yet!" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - else { - injectionQueue->setDefaultDestination(targetQueue->getRequestQueue()); - } + // Prepare message queue which is used to send telecommands. + injectionQueue = QueueFactory::instance()->createMessageQueue(INJECTION_QUEUE_DEPTH); + AcceptsTelecommandsIF* targetQueue = + ObjectManager::instance()->get(destination); + if (targetQueue == nullptr) { + sif::error << "PusTcInjector: CCSDS distributor not initialized yet!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } else { + injectionQueue->setDefaultDestination(targetQueue->getRequestQueue()); + } - // Prepare store used to store TC messages - tcStore = ObjectManager::instance()->get(tcStoreId); - if(tcStore == nullptr) { - sif::error << "PusTcInjector: TC Store not initialized!" << std::endl; - return ObjectManagerIF::CHILD_INIT_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + // Prepare store used to store TC messages + tcStore = ObjectManager::instance()->get(tcStoreId); + if (tcStore == nullptr) { + sif::error << "PusTcInjector: TC Store not initialized!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/test/testtasks/PusTcInjector.h b/test/testtasks/PusTcInjector.h index df67e403..4d1cea7e 100644 --- a/test/testtasks/PusTcInjector.h +++ b/test/testtasks/PusTcInjector.h @@ -3,70 +3,71 @@ #include #include #include + #include -class PusTcInjector: public SystemObject { -public: - static constexpr uint8_t INJECTION_QUEUE_DEPTH = 10; - const uint16_t defaultApid; +class PusTcInjector : public SystemObject { + public: + static constexpr uint8_t INJECTION_QUEUE_DEPTH = 10; + const uint16_t defaultApid; - /** - * Initialize a software telecommand injector by supplying object IDs to - * various helper objects which must exist before calling initialiez() - * @param objectId ID of PUS telecommand injector - * @param destination ID of destination, which has to implement - * AcceptsTelecommandIF. - * @param tcStore ID of telecommand store, which has to implement - * StorageManagerIF. - * @param defaultApid Default APID which will be used if an injection - * without an APID is requested. - */ - PusTcInjector(object_id_t objectId, object_id_t destination, - object_id_t tcStore, uint16_t defaultApid); - /** - * This has to be called before using the PusTcInjector. - * Call Not necessary when using a factory and the object manager. - * @return -@c RETURN_OK for successfull init - * -@c ObjectManagerIF::CHILD_INIT_FAILED otherwise - */ - ReturnValue_t initialize() override; + /** + * Initialize a software telecommand injector by supplying object IDs to + * various helper objects which must exist before calling initialiez() + * @param objectId ID of PUS telecommand injector + * @param destination ID of destination, which has to implement + * AcceptsTelecommandIF. + * @param tcStore ID of telecommand store, which has to implement + * StorageManagerIF. + * @param defaultApid Default APID which will be used if an injection + * without an APID is requested. + */ + PusTcInjector(object_id_t objectId, object_id_t destination, object_id_t tcStore, + uint16_t defaultApid); + /** + * This has to be called before using the PusTcInjector. + * Call Not necessary when using a factory and the object manager. + * @return -@c RETURN_OK for successfull init + * -@c ObjectManagerIF::CHILD_INIT_FAILED otherwise + */ + ReturnValue_t initialize() override; - virtual~ PusTcInjector(); + virtual ~PusTcInjector(); - /** - * Can be used to inject a telecommand by supplying service, subservice - * and optional application data and its length. - * Default APID will be used. - * @param service PUS service type - * @param subservice PUS subservice type - * @param appData Pointer to application data - * @param appDataLen Length of application data - * @return - */ - //ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, - // const uint8_t* appData = nullptr, size_t appDataLen = 0); + /** + * Can be used to inject a telecommand by supplying service, subservice + * and optional application data and its length. + * Default APID will be used. + * @param service PUS service type + * @param subservice PUS subservice type + * @param appData Pointer to application data + * @param appDataLen Length of application data + * @return + */ + // ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, + // const uint8_t* appData = nullptr, size_t appDataLen = 0); - /** - * Provides the same functionality while also setting a user defined APID. - * @param service PUS service type - * @param subservice PUS subservice type - * @param apid Custom APID to, - * @param appData Pointer to application data - * @param appDataLen Length of application data - * @return - */ - //ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, - // uint16_t apid, const uint8_t* appData = nullptr, - // size_t appDataLen = 0); -private: - MessageQueueIF* injectionQueue = nullptr; - StorageManagerIF *tcStore = nullptr; + /** + * Provides the same functionality while also setting a user defined APID. + * @param service PUS service type + * @param subservice PUS subservice type + * @param apid Custom APID to, + * @param appData Pointer to application data + * @param appDataLen Length of application data + * @return + */ + // ReturnValue_t injectPusTelecommand(uint8_t service, uint8_t subservice, + // uint16_t apid, const uint8_t* appData = nullptr, + // size_t appDataLen = 0); + private: + MessageQueueIF* injectionQueue = nullptr; + StorageManagerIF* tcStore = nullptr; - /* Cached for initialize function */ - object_id_t destination = 0; - object_id_t tcStoreId = 0; + /* Cached for initialize function */ + object_id_t destination = 0; + object_id_t tcStoreId = 0; - uint16_t sequenceCount = 0; + uint16_t sequenceCount = 0; }; #endif /* TEST_TESTTASKS_PUSTCINJECTOR_H_ */ diff --git a/test/testtasks/TestTask.cpp b/test/testtasks/TestTask.cpp index 6a90cc08..911767af 100644 --- a/test/testtasks/TestTask.cpp +++ b/test/testtasks/TestTask.cpp @@ -1,45 +1,43 @@ #include "TestTask.h" -#include "OBSWConfig.h" +#include +#include #include #include -#include #include -#include #include #include +#include "OBSWConfig.h" -EiveTestTask::EiveTestTask(object_id_t objectId_): TestTask(objectId_), testMode(testModes::A) { - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); +EiveTestTask::EiveTestTask(object_id_t objectId_) : TestTask(objectId_), testMode(testModes::A) { + IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); } -EiveTestTask::~EiveTestTask() { -} +EiveTestTask::~EiveTestTask() {} ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = RETURN_OK; - if(oneShotAction) { - /* Add code here which should only be run once */ - performOneShotAction(); - oneShotAction = false; - } + if (oneShotAction) { + /* Add code here which should only be run once */ + performOneShotAction(); + oneShotAction = false; + } - /* Add code here which should only be run once per performOperation */ - performPeriodicAction(); + /* Add code here which should only be run once per performOperation */ + performPeriodicAction(); - /* Add code here which should only be run on alternating cycles. */ - if(testMode == testModes::A) { - performActionA(); - testMode = testModes::B; - } - else if(testMode == testModes::B) { - performActionB(); - testMode = testModes::A; - } - return result; + /* Add code here which should only be run on alternating cycles. */ + if (testMode == testModes::A) { + performActionA(); + testMode = testModes::B; + } else if (testMode == testModes::B) { + performActionB(); + testMode = testModes::A; + } + return result; } #include @@ -48,70 +46,70 @@ ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { /** * @brief Dummy data from GPS receiver. Will be replaced witgh hyperion data later. */ -const char -gps_rx_data[] = "" - "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" - "$GPRMB,A,,,,,,,,,,,,V*71\r\n" - "$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" - "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" - "$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" - "$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" - "$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" - "$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" - "$PGRMZ,2062,f,3*2D\r\n" - "$PGRMM,WGS84*06\r\n" - "$GPBOD,,T,,M,,*47\r\n" - "$GPRTE,1,1,c,0*07\r\n" - "$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" - "$GPRMB,A,,,,,,,,,,,,V*71\r\n"; +const char gps_rx_data[] = + "" + "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n" + "$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" + "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" + "$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" + "$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" + "$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" + "$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" + "$PGRMZ,2062,f,3*2D\r\n" + "$PGRMM,WGS84*06\r\n" + "$GPBOD,,T,,M,,*47\r\n" + "$GPRTE,1,1,c,0*07\r\n" + "$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n"; -const char hyperion_gps_data[] = "" - "$GNGGA,173225.998892,4908.5596,N,00906.2765,E,1,05,2.1,215.0,M,48.2,M,,0000*74\r\n" - "$GNGLL,4908.5596,N,00906.2765,E,173225.998892,A,A*7F\r\n" - "$GPGSA,A,3,18,16,26,31,20,,,,,,,,3.2,2.1,2.4*3C\r\n" - "$GNRMC,173225.998892,A,4908.5596,N,00906.2765,E,000.0,040.7,270221,,,A*4F\r\n" - "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" - "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; +const char hyperion_gps_data[] = + "" + "$GNGGA,173225.998892,4908.5596,N,00906.2765,E,1,05,2.1,215.0,M,48.2,M,,0000*74\r\n" + "$GNGLL,4908.5596,N,00906.2765,E,173225.998892,A,A*7F\r\n" + "$GPGSA,A,3,18,16,26,31,20,,,,,,,,3.2,2.1,2.4*3C\r\n" + "$GNRMC,173225.998892,A,4908.5596,N,00906.2765,E,000.0,040.7,270221,,,A*4F\r\n" + "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" + "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; ReturnValue_t EiveTestTask::performOneShotAction() { #if OBSW_ADD_TEST_CODE == 1 - //performLwgpsTest(); + // performLwgpsTest(); #endif - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } - ReturnValue_t EiveTestTask::performPeriodicAction() { - ReturnValue_t result = RETURN_OK; - return result; + ReturnValue_t result = RETURN_OK; + return result; } ReturnValue_t EiveTestTask::performActionA() { - ReturnValue_t result = RETURN_OK; - /* Add periodically executed code here */ - return result; + ReturnValue_t result = RETURN_OK; + /* Add periodically executed code here */ + return result; } ReturnValue_t EiveTestTask::performActionB() { - ReturnValue_t result = RETURN_OK; - /* Add periodically executed code here */ - return result; + ReturnValue_t result = RETURN_OK; + /* Add periodically executed code here */ + return result; } void EiveTestTask::performLwgpsTest() { - /* Everything here will only be performed once. */ - sif::info << "Processing sample GPS output.." << std::endl; + /* Everything here will only be performed once. */ + sif::info << "Processing sample GPS output.." << std::endl; - lwgps_t gpsStruct; - sif::info << "Size of GPS struct: " << sizeof(gpsStruct) << std::endl; - lwgps_init(&gpsStruct); + lwgps_t gpsStruct; + sif::info << "Size of GPS struct: " << sizeof(gpsStruct) << std::endl; + lwgps_init(&gpsStruct); - /* Process all input data */ - lwgps_process(&gpsStruct, hyperion_gps_data, strlen(hyperion_gps_data)); + /* Process all input data */ + lwgps_process(&gpsStruct, hyperion_gps_data, strlen(hyperion_gps_data)); - /* Print messages */ - printf("Valid status: %d\n", gpsStruct.is_valid); - printf("Latitude: %f degrees\n", gpsStruct.latitude); - printf("Longitude: %f degrees\n", gpsStruct.longitude); - printf("Altitude: %f meters\n", gpsStruct.altitude); + /* Print messages */ + printf("Valid status: %d\n", gpsStruct.is_valid); + printf("Latitude: %f degrees\n", gpsStruct.latitude); + printf("Longitude: %f degrees\n", gpsStruct.longitude); + printf("Altitude: %f meters\n", gpsStruct.altitude); } diff --git a/test/testtasks/TestTask.h b/test/testtasks/TestTask.h index c2b8c8ed..2040ffb5 100644 --- a/test/testtasks/TestTask.h +++ b/test/testtasks/TestTask.h @@ -2,12 +2,12 @@ #define TEST_TESTTASK_H_ #include -#include #include -#include "fsfw_tests/integration/task/TestTask.h" +#include #include +#include "fsfw_tests/integration/task/TestTask.h" /** * @brief Test class for general C++ testing. @@ -16,38 +16,35 @@ * tests. Instead, a derived board test class should be used. */ class EiveTestTask : public TestTask { -public: - EiveTestTask(object_id_t objectId); - virtual ~EiveTestTask(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + public: + EiveTestTask(object_id_t objectId); + virtual ~EiveTestTask(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; -protected: - virtual ReturnValue_t performOneShotAction(); - virtual ReturnValue_t performPeriodicAction(); - virtual ReturnValue_t performActionA(); - virtual ReturnValue_t performActionB(); + protected: + virtual ReturnValue_t performOneShotAction(); + virtual ReturnValue_t performPeriodicAction(); + virtual ReturnValue_t performActionA(); + virtual ReturnValue_t performActionB(); - enum testModes: uint8_t { - A, - B - }; + enum testModes : uint8_t { A, B }; - testModes testMode; + testModes testMode; - bool testFlag = false; - uint8_t counter { 1 }; - uint8_t counterTrigger { 3 }; + bool testFlag = false; + uint8_t counter{1}; + uint8_t counterTrigger{3}; - void performPusInjectorTest(); - void examplePacketTest(); -private: - // Actually, to be really thread-safe, a mutex should be used as well - // Let's keep it simple for now. - bool oneShotAction = true; - StorageManagerIF* IPCStore; + void performPusInjectorTest(); + void examplePacketTest(); - void performLwgpsTest(); + private: + // Actually, to be really thread-safe, a mutex should be used as well + // Let's keep it simple for now. + bool oneShotAction = true; + StorageManagerIF* IPCStore; + + void performLwgpsTest(); }; - #endif /* TESTTASK_H_ */