PLOC SUPV Update to newer firmware #316

Merged
muellerr merged 99 commits from mueller/tas_ploc_supv_update into develop 2022-11-18 14:27:13 +01:00
5 changed files with 132 additions and 18 deletions
Showing only changes of commit de66ac66c6 - Show all commits

2
fsfw

@ -1 +1 @@
Subproject commit 84b9d1ce216c076bdfeeaf1663aa873c7f1c9cff Subproject commit 672fca5169b017387e58e2ff864913d932c59aa1

View File

@ -98,18 +98,11 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) {
} }
// Setting up UART parameters // Setting up UART parameters
tty.c_cflag &= ~PARENB; // Clear parity bit tty.c_cflag &= ~PARENB; // Clear parity bit
if (uartCookie->getStopBits() == StopBits::TWO_STOP_BITS) { uart::setStopbits(tty, uartCookie->getStopBits());
// Use two stop bits uart::setBitsPerWord(tty, BitsPerWord::BITS_8);
tty.c_cflag |= CSTOPB;
} else {
// Clear stop field, only one stop bit used in communication
tty.c_cflag &= ~CSTOPB;
}
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 &= ~CRTSCTS; // Disable RTS/CTS hardware flow control
tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) uart::enableRead(tty);
uart::ignoreCtrlLines(tty);
// Use non-canonical mode and clear echo flag // Use non-canonical mode and clear echo flag
tty.c_lflag &= ~(ICANON | ECHO); tty.c_lflag &= ~(ICANON | ECHO);

View File

@ -150,7 +150,7 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
if (size > config::MAX_PATH_SIZE) { if (size > config::MAX_PATH_SIZE) {
return SupvReturnValuesIF::FILENAME_TOO_LONG; return SupvReturnValuesIF::FILENAME_TOO_LONG;
} }
result = supvHelper->startEventbBufferRequest( result = supvHelper->startEventBufferRequest(
std::string(reinterpret_cast<const char*>(data), size)); std::string(reinterpret_cast<const char*>(data), size));
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;

View File

@ -1,7 +1,9 @@
#include "PlocSupvHelper.h" #include "PlocSupvHelper.h"
#include <etl/crc16_ccitt.h> #include <etl/crc16_ccitt.h>
#include <fcntl.h> // Contains file controls like O_RDWR
#include <fsfw/filesystem/HasFileSystemIF.h> #include <fsfw/filesystem/HasFileSystemIF.h>
#include <unistd.h>
#include <cmath> #include <cmath>
#include <filesystem> #include <filesystem>
@ -15,11 +17,14 @@
#include "fsfw/tasks/TaskFactory.h" #include "fsfw/tasks/TaskFactory.h"
#include "fsfw/timemanager/Countdown.h" #include "fsfw/timemanager/Countdown.h"
#include "fsfw_hal/linux/uart/helper.h"
#include "mission/utility/Filenaming.h" #include "mission/utility/Filenaming.h"
#include "mission/utility/ProgressPrinter.h" #include "mission/utility/ProgressPrinter.h"
#include "mission/utility/Timestamp.h" #include "mission/utility/Timestamp.h"
PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId) { using namespace returnvalue;
PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId), ringBuf(4096, true) {
spParams.maxSize = sizeof(commandBuffer); spParams.maxSize = sizeof(commandBuffer);
resetSpParams(); resetSpParams();
} }
@ -187,7 +192,7 @@ void PlocSupvHelper::initiateUpdateContinuation() {
semaphore.release(); semaphore.release();
} }
ReturnValue_t PlocSupvHelper::startEventbBufferRequest(std::string path) { ReturnValue_t PlocSupvHelper::startEventBufferRequest(std::string path) {
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
ReturnValue_t result = FilesystemHelper::checkPath(path); ReturnValue_t result = FilesystemHelper::checkPath(path);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -801,3 +806,58 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception(ploc::SpTmReader& reade
} }
void PlocSupvHelper::resetSpParams() { spParams.buf = commandBuffer; } void PlocSupvHelper::resetSpParams() { spParams.buf = commandBuffer; }
ReturnValue_t PlocSupvHelper::initializeInterface(CookieIF* cookie) {
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) {
return FAILED;
}
std::string devname = uartCookie->getDeviceFile();
/* Get file descriptor */
serialPort = open(devname.c_str(), O_RDWR);
if (serialPort < 0) {
sif::warning << "ScexUartReader::initializeInterface: open call failed with error [" << errno
<< ", " << strerror(errno) << std::endl;
return FAILED;
}
// Setting up UART parameters
tty.c_cflag &= ~PARENB; // Clear parity bit
uart::setParity(tty, uartCookie->getParity());
uart::setStopbits(tty, uartCookie->getStopBits());
uart::setBitsPerWord(tty, BitsPerWord::BITS_8);
tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control
uart::enableRead(tty);
uart::ignoreCtrlLines(tty);
// Use non-canonical mode and clear echo flag
tty.c_lflag &= ~(ICANON | ECHO);
// Non-blocking mode, 0.5 seconds timeout
tty.c_cc[VTIME] = 5;
tty.c_cc[VMIN] = 0;
uart::setBaudrate(tty, uartCookie->getBaudrate());
if (tcsetattr(serialPort, TCSANOW, &tty) != 0) {
sif::warning << "ScexUartReader::initializeInterface: tcsetattr call failed with error ["
<< errno << ", " << strerror(errno) << std::endl;
}
// Flush received and unread data
tcflush(serialPort, TCIOFLUSH);
return OK;
}
ReturnValue_t PlocSupvHelper::sendMessage(CookieIF* cookie, const uint8_t* sendData,
size_t sendLen) {
return returnvalue::OK;
}
ReturnValue_t PlocSupvHelper::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; }
ReturnValue_t PlocSupvHelper::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
return returnvalue::OK;
}
ReturnValue_t PlocSupvHelper::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
size_t* size) {
return returnvalue::OK;
}

View File

@ -1,6 +1,9 @@
#ifndef BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ #ifndef BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_
#define BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ #define BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_
#include <fsfw/container/SimpleRingBuffer.h>
#include <termios.h>
#include <string> #include <string>
#include "OBSWConfig.h" #include "OBSWConfig.h"
@ -21,7 +24,9 @@
* the supervisor and the OBC. * the supervisor and the OBC.
* @author J. Meier * @author J. Meier
*/ */
class PlocSupvHelper : public SystemObject, public ExecutableObjectIF { class PlocSupvHelper : public DeviceCommunicationIF,
public SystemObject,
public ExecutableObjectIF {
public: public:
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPV_HELPER; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPV_HELPER;
@ -131,7 +136,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF {
/** /**
* @brief Calling this function will initiate the procedure to request the event buffer * @brief Calling this function will initiate the procedure to request the event buffer
*/ */
ReturnValue_t startEventbBufferRequest(std::string path); ReturnValue_t startEventBufferRequest(std::string path);
/** /**
* @brief Can be used to interrupt a running data transfer. * @brief Can be used to interrupt a running data transfer.
@ -181,6 +186,9 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF {
struct Update update; struct Update update;
int serialPort = 0;
struct termios tty = {};
struct EventBufferRequest { struct EventBufferRequest {
std::string path = ""; std::string path = "";
// Default name of file where event buffer data will be written to. Timestamp will be added to // Default name of file where event buffer data will be written to. Timestamp will be added to
@ -206,6 +214,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF {
bool terminate = false; bool terminate = false;
SimpleRingBuffer ringBuf;
/** /**
* Communication interface responsible for data transactions between OBC and Supervisor. * Communication interface responsible for data transactions between OBC and Supervisor.
*/ */
@ -272,6 +281,58 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF {
ReturnValue_t handleRemainingExeReport(ploc::SpTmReader& reader); ReturnValue_t handleRemainingExeReport(ploc::SpTmReader& reader);
void resetSpParams(); void resetSpParams();
/**
* @brief Device specific initialization, using the cookie.
* @details
* The cookie is already prepared in the factory. If the communication
* interface needs to be set up in some way and requires cookie information,
* this can be performed in this function, which is called on device handler
* initialization.
* @param cookie
* @return
* - @c returnvalue::OK if initialization was successfull
* - Everything else triggers failure event with returnvalue as parameter 1
*/
ReturnValue_t initializeInterface(CookieIF* cookie) override;
/**
* Called by DHB in the SEND_WRITE doSendWrite().
* This function is used to send data to the physical device
* by implementing and calling related drivers or wrapper functions.
* @param cookie
* @param data
* @param len If this is 0, nothing shall be sent.
* @return
* - @c returnvalue::OK for successfull send
* - Everything else triggers failure event with returnvalue as parameter 1
*/
ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override;
/**
* Called by DHB in the GET_WRITE doGetWrite().
* Get send confirmation that the data in sendMessage() was sent successfully.
* @param cookie
* @return
* - @c returnvalue::OK if data was sent successfully but a reply is expected
* - NO_REPLY_EXPECTED if data was sent successfully and no reply is expected
* - Everything else to indicate failure
*/
ReturnValue_t getSendSuccess(CookieIF* cookie) override;
/**
* Called by DHB in the SEND_WRITE doSendRead().
* It is assumed that it is always possible to request a reply
* from a device. If a requestLen of 0 is supplied, no reply was enabled
* and communication specific action should be taken (e.g. read nothing
* or read everything).
*
* @param cookie
* @param requestLen Size of data to read
* @return - @c returnvalue::OK to confirm the request for data has been sent.
* - Everything else triggers failure event with
* returnvalue as parameter 1
*/
ReturnValue_t requestReceiveMessage(CookieIF* cookie, size_t requestLen) override;
ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override;
}; };
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */ #endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */