2021-12-21 15:46:09 +01:00
|
|
|
#ifndef BSP_Q7S_DEVICES_STRHELPER_H_
|
|
|
|
#define BSP_Q7S_DEVICES_STRHELPER_H_
|
2021-11-30 16:01:02 +01:00
|
|
|
|
|
|
|
#include <string>
|
2021-12-07 16:30:17 +01:00
|
|
|
#include "ArcsecDatalinkLayer.h"
|
2021-11-30 16:01:02 +01:00
|
|
|
#include "fsfw/osal/linux/BinarySemaphore.h"
|
|
|
|
#include "bsp_q7s/memory/SdCardManager.h"
|
2021-12-02 08:05:33 +01:00
|
|
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
2021-12-06 19:36:21 +01:00
|
|
|
#include "fsfw/objectmanager/SystemObject.h"
|
|
|
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
2021-12-10 10:07:23 +01:00
|
|
|
#include "fsfw_hal/linux/uart/UartComIF.h"
|
2021-12-06 19:36:21 +01:00
|
|
|
#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"
|
|
|
|
}
|
2021-11-30 16:01:02 +01:00
|
|
|
|
|
|
|
/**
|
2021-12-21 15:46:09 +01:00
|
|
|
* @brief Helper class for the star tracker handler to accelerate large data transfers.
|
2021-11-30 16:01:02 +01:00
|
|
|
*/
|
2021-12-21 15:46:09 +01:00
|
|
|
class StrHelper: public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF {
|
2021-11-30 16:01:02 +01:00
|
|
|
public:
|
2021-12-02 08:05:33 +01:00
|
|
|
|
2021-12-21 15:46:09 +01:00
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HELPER;
|
2021-12-02 08:05:33 +01:00
|
|
|
|
2021-12-10 10:07:23 +01:00
|
|
|
//! [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);
|
2021-12-29 20:33:20 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Uploading image to star tracker was successfulop
|
2021-12-10 10:07:23 +01:00
|
|
|
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);
|
2021-12-21 15:46:09 +01:00
|
|
|
//! [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);
|
2021-12-29 20:33:20 +01:00
|
|
|
//! [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);
|
2021-12-02 08:05:33 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Failed to read communication interface reply data
|
|
|
|
//!P1: Return code of failed communication interface read call
|
2021-12-09 15:02:58 +01:00
|
|
|
//!P1: Upload/download position for which the read call failed
|
2021-12-29 20:33:20 +01:00
|
|
|
static const Event STR_HELPER_READING_REPLY_FAILED = MAKE_EVENT(12, severity::LOW);
|
2021-12-02 08:05:33 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Unexpected stop of decoding sequence
|
|
|
|
//!P1: Return code of failed communication interface read call
|
2021-12-09 15:02:58 +01:00
|
|
|
//!P1: Upload/download position for which the read call failed
|
2021-12-29 20:33:20 +01:00
|
|
|
static const Event STR_HELPER_COM_ERROR = MAKE_EVENT(13, severity::LOW);
|
2021-12-06 19:36:21 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Star tracker did not send replies (maybe device is powered off)
|
2021-12-09 15:02:58 +01:00
|
|
|
//!P1: Position of upload or download packet for which no reply was sent
|
2021-12-29 20:33:20 +01:00
|
|
|
static const Event STR_HELPER_NO_REPLY = MAKE_EVENT(14, severity::LOW);
|
2021-12-06 19:36:21 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Error during decoding of received reply occurred
|
|
|
|
//P1: Return value of decoding function
|
2021-12-21 15:46:09 +01:00
|
|
|
//P2: Position of upload/download packet, or address of flash write/read request
|
2021-12-29 20:33:20 +01:00
|
|
|
static const Event STR_HELPER_DEC_ERROR = MAKE_EVENT(15, severity::LOW);
|
2021-12-09 15:02:58 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Position mismatch
|
|
|
|
//! P1: The expected position and thus the position for which the image upload/download failed
|
2021-12-29 20:33:20 +01:00
|
|
|
static const Event POSITION_MISMATCH = MAKE_EVENT(16, severity::LOW);
|
2021-12-21 15:46:09 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Specified file does not exist
|
|
|
|
//!P1: Internal state of str helper
|
2021-12-29 20:33:20 +01:00
|
|
|
static const Event STR_HELPER_FILE_NOT_EXISTS = MAKE_EVENT(17, severity::LOW);
|
2021-12-21 15:46:09 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Sending packet to star tracker failed
|
2021-12-10 10:07:23 +01:00
|
|
|
//!P1: Return code of communication interface sendMessage function
|
2021-12-21 15:46:09 +01:00
|
|
|
//!P2: Position of upload/download packet, or address of flash write/read request for which sending failed
|
2021-12-29 20:33:20 +01:00
|
|
|
static const Event STR_HELPER_SENDING_PACKET_FAILED = MAKE_EVENT(18, severity::LOW);
|
2021-12-10 10:07:23 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Communication interface requesting reply failed
|
|
|
|
//!P1: Return code of failed request
|
2021-12-21 15:46:09 +01:00
|
|
|
//!P1: Upload/download position, or address of flash write/read request for which transmission failed
|
2021-12-29 20:33:20 +01:00
|
|
|
static const Event STR_HELPER_REQUESTING_MSG_FAILED = MAKE_EVENT(19, severity::LOW);
|
2021-12-10 10:07:23 +01:00
|
|
|
|
2021-12-21 15:46:09 +01:00
|
|
|
StrHelper(object_id_t objectId);
|
|
|
|
virtual ~StrHelper();
|
2021-11-30 16:01:02 +01:00
|
|
|
|
2021-12-06 19:36:21 +01:00
|
|
|
ReturnValue_t initialize() override;
|
2021-11-30 16:01:02 +01:00
|
|
|
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
|
|
|
|
2021-12-10 10:07:23 +01:00
|
|
|
ReturnValue_t setComIF(DeviceCommunicationIF* communicationInterface_);
|
2021-11-30 16:01:02 +01:00
|
|
|
void setComCookie(CookieIF* comCookie_);
|
|
|
|
|
2021-12-02 08:05:33 +01:00
|
|
|
/**
|
|
|
|
* @brief Starts sequence to upload image to star tracker
|
|
|
|
*
|
2021-12-30 13:31:34 +01:00
|
|
|
* @param uploadImage_ Name including absolute path of the image to upload. Must be previously
|
|
|
|
* transferred to the OBC with the CFDP protocol.
|
2021-12-02 08:05:33 +01:00
|
|
|
*/
|
2021-12-11 11:56:47 +01:00
|
|
|
ReturnValue_t startImageUpload(std::string uploadImage_);
|
2021-12-02 08:05:33 +01:00
|
|
|
|
2021-12-06 19:36:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Calling this function initiates the download of an image from the star tracker.
|
2021-12-11 11:56:47 +01:00
|
|
|
*
|
2021-12-30 13:31:34 +01:00
|
|
|
* @param path Path where downloaded image will be stored
|
2021-12-06 19:36:21 +01:00
|
|
|
*/
|
2021-12-30 13:31:34 +01:00
|
|
|
ReturnValue_t startImageDownload(std::string path);
|
2021-12-06 19:36:21 +01:00
|
|
|
|
2021-12-10 10:07:23 +01:00
|
|
|
/**
|
2021-12-21 15:46:09 +01:00
|
|
|
* @brief Starts the flash write procedure
|
|
|
|
*
|
2021-12-30 13:31:34 +01:00
|
|
|
* @param fullname Full name including absolute path of file to write to flash
|
2021-12-21 15:46:09 +01:00
|
|
|
* @param region Region ID of flash region to write to
|
2021-12-22 16:06:30 +01:00
|
|
|
* @param address Start address of flash write procedure
|
2021-12-21 15:46:09 +01:00
|
|
|
*/
|
2021-12-30 13:31:34 +01:00
|
|
|
ReturnValue_t startFlashWrite(std::string fullname, uint8_t region, uint32_t address);
|
2021-12-22 16:06:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Starts the flash read procedure
|
|
|
|
*
|
2021-12-30 13:31:34 +01:00
|
|
|
* @param path Path where file with read flash data will be created
|
2021-12-22 16:06:30 +01:00
|
|
|
* @param region Region ID of flash region to read from
|
2021-12-30 13:31:34 +01:00
|
|
|
* @param address Start address of flash section to read
|
2021-12-22 16:06:30 +01:00
|
|
|
* @param length Number of bytes to read from flash
|
|
|
|
*/
|
2021-12-30 13:31:34 +01:00
|
|
|
ReturnValue_t startFlashRead(std::string path, uint8_t region, uint32_t address,
|
|
|
|
uint32_t length);
|
2021-12-21 15:46:09 +01:00
|
|
|
|
2021-12-29 20:33:20 +01:00
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
|
2021-12-30 12:52:08 +01:00
|
|
|
/**
|
|
|
|
* @brief Starts upload of new image to FPGA
|
|
|
|
*
|
|
|
|
* @param uploadFile Full name of file containing FPGA image data
|
|
|
|
*/
|
|
|
|
ReturnValue_t startFpgaUpload(std::string uploadFile);
|
|
|
|
|
2021-12-21 15:46:09 +01:00
|
|
|
/**
|
|
|
|
* @brief Can be used to interrupt a running data transfer.
|
2021-12-10 10:07:23 +01:00
|
|
|
*/
|
|
|
|
void stopProcess();
|
|
|
|
|
2021-12-11 11:56:47 +01:00
|
|
|
/**
|
|
|
|
* @brief Changes the dafault name of downloaded images
|
|
|
|
*/
|
2021-12-30 13:31:34 +01:00
|
|
|
void setDownloadImageName(std::string filename);
|
2021-12-11 11:56:47 +01:00
|
|
|
|
2021-12-22 16:06:30 +01:00
|
|
|
/**
|
|
|
|
* @brief Sets the name of the file which will be created to store the data read from flash
|
|
|
|
*/
|
|
|
|
void setFlashReadFilename(std::string filename);
|
|
|
|
|
2021-12-30 12:52:08 +01:00
|
|
|
/**
|
|
|
|
* @brief Set download FPGA image name
|
|
|
|
*/
|
|
|
|
void setDownloadFpgaImage(std::string filename);
|
|
|
|
|
2021-11-30 16:01:02 +01:00
|
|
|
private:
|
|
|
|
|
2021-12-21 15:46:09 +01:00
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::STR_HELPER;
|
2021-11-30 16:01:02 +01:00
|
|
|
|
|
|
|
//! [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);
|
2021-12-11 11:56:47 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Specified path does not exist
|
|
|
|
static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2);
|
2021-12-21 15:46:09 +01:00
|
|
|
//! [EXPORT] : [COMMENT] Failed to create download image or read flash file
|
2021-12-11 11:56:47 +01:00
|
|
|
static const ReturnValue_t FILE_CREATION_FAILED = MAKE_RETURN_CODE(0xA3);
|
2021-12-21 15:46:09 +01:00
|
|
|
//! [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);
|
2021-12-23 11:07:19 +01:00
|
|
|
//! [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);
|
2021-11-30 16:01:02 +01:00
|
|
|
|
2021-12-02 08:05:33 +01:00
|
|
|
// Size of one image part which can be sent per action request
|
|
|
|
static const size_t SIZE_IMAGE_PART = 1024;
|
|
|
|
|
2021-12-29 20:33:20 +01:00
|
|
|
class ImageDownload {
|
|
|
|
public:
|
|
|
|
static const uint32_t LAST_POSITION = 4095;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FpgaDownload {
|
|
|
|
public:
|
|
|
|
static const uint16_t MAX_DATA = 1024;
|
2021-12-30 12:52:08 +01:00
|
|
|
static const uint8_t DATA_OFFSET = 10;
|
2021-12-29 20:33:20 +01:00
|
|
|
// 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;
|
2021-12-09 15:02:58 +01:00
|
|
|
|
2021-12-30 12:52:08 +01:00
|
|
|
class FpgaUpload {
|
|
|
|
public:
|
|
|
|
static const uint32_t MAX_DATA = 1024;
|
|
|
|
// Full name of file to upload
|
|
|
|
std::string uploadFile;
|
|
|
|
};
|
|
|
|
FpgaUpload fpgaUpload;
|
|
|
|
|
2021-12-06 19:36:21 +01:00
|
|
|
static const uint32_t MAX_POLLS = 10000;
|
|
|
|
|
2021-12-30 12:52:08 +01:00
|
|
|
static const uint8_t ACTION_DATA_OFFSET = 2;
|
2021-12-09 15:02:58 +01:00
|
|
|
static const uint8_t POS_OFFSET = 2;
|
2021-12-22 16:06:30 +01:00
|
|
|
static const uint8_t IMAGE_DATA_OFFSET = 5;
|
|
|
|
static const uint8_t FLASH_READ_DATA_OFFSET = 8;
|
2021-12-21 15:46:09 +01:00
|
|
|
static const uint8_t REGION_OFFSET = 2;
|
|
|
|
static const uint8_t ADDRESS_OFFSET = 3;
|
|
|
|
static const uint8_t LENGTH_OFFSET = 7;
|
2021-12-09 15:02:58 +01:00
|
|
|
static const size_t IMAGE_DATA_SIZE = 1024;
|
2021-12-21 15:46:09 +01:00
|
|
|
static const size_t MAX_FLASH_DATA = 1024;
|
2021-12-10 10:07:23 +01:00
|
|
|
static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3;
|
2021-12-09 15:02:58 +01:00
|
|
|
|
2021-11-30 16:01:02 +01:00
|
|
|
enum class InternalState {
|
|
|
|
IDLE,
|
|
|
|
UPLOAD_IMAGE,
|
2021-12-21 15:46:09 +01:00
|
|
|
DOWNLOAD_IMAGE,
|
|
|
|
FLASH_WRITE,
|
2021-12-29 20:33:20 +01:00
|
|
|
FLASH_READ,
|
|
|
|
DOWNLOAD_FPGA_IMAGE,
|
|
|
|
UPLOAD_FPGA_IMAGE
|
2021-11-30 16:01:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
InternalState internalState = InternalState::IDLE;
|
|
|
|
|
2021-12-02 08:05:33 +01:00
|
|
|
ArcsecDatalinkLayer datalinkLayer;
|
|
|
|
|
2021-11-30 16:01:02 +01:00
|
|
|
BinarySemaphore semaphore;
|
|
|
|
|
2021-12-30 13:31:34 +01:00
|
|
|
class UploadImage {
|
|
|
|
public:
|
|
|
|
// Name including absolute path of image to upload
|
|
|
|
std::string uploadFile;
|
|
|
|
};
|
|
|
|
UploadImage uploadImage;
|
|
|
|
|
|
|
|
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 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 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;
|
2021-11-30 16:01:02 +01:00
|
|
|
|
|
|
|
SdCardManager* sdcMan = nullptr;
|
|
|
|
|
2021-12-06 19:36:21 +01:00
|
|
|
uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE];
|
|
|
|
|
2021-12-10 10:07:23 +01:00
|
|
|
bool terminate = false;
|
|
|
|
|
2021-11-30 16:01:02 +01:00
|
|
|
/**
|
2021-12-10 10:07:23 +01:00
|
|
|
* UART communication object responsible for low level access of star tracker
|
2021-11-30 16:01:02 +01:00
|
|
|
* Must be set by star tracker handler
|
|
|
|
*/
|
2021-12-10 10:07:23 +01:00
|
|
|
UartComIF* uartComIF = nullptr;
|
2021-12-02 08:05:33 +01:00
|
|
|
// Communication cookie. Must be set by the star tracker handler
|
|
|
|
CookieIF* comCookie = nullptr;
|
|
|
|
|
2021-12-06 19:36:21 +01:00
|
|
|
// Queue id of raw data receiver
|
|
|
|
MessageQueueId_t rawDataReceiver = MessageQueueIF::NO_QUEUE;
|
|
|
|
|
2021-12-02 08:05:33 +01:00
|
|
|
/**
|
|
|
|
* @brief Performs image uploading
|
|
|
|
*/
|
2021-12-06 19:36:21 +01:00
|
|
|
ReturnValue_t performImageUpload();
|
|
|
|
|
|
|
|
/**
|
2021-12-14 19:24:31 +01:00
|
|
|
* @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.
|
2021-12-09 15:02:58 +01:00
|
|
|
*/
|
|
|
|
ReturnValue_t performImageDownload();
|
|
|
|
|
2021-12-21 15:46:09 +01:00
|
|
|
/**
|
|
|
|
* @brief Handles flash write procedure
|
|
|
|
*
|
|
|
|
* @return RETURN_OK if successful, otherwise RETURN_FAILED
|
|
|
|
*/
|
|
|
|
ReturnValue_t performFlashWrite();
|
|
|
|
|
2021-12-22 16:06:30 +01:00
|
|
|
/**
|
|
|
|
* @brief Sends a sequence of commands to the star tracker to read larger parts from the
|
|
|
|
* flash memory.
|
|
|
|
*/
|
|
|
|
ReturnValue_t performFlashRead();
|
|
|
|
|
2021-12-29 20:33:20 +01:00
|
|
|
/**
|
|
|
|
* @brief Performs the download of the FPGA image which requires to be slip over multiple
|
|
|
|
* action requests.
|
|
|
|
*/
|
|
|
|
ReturnValue_t performFpgaDownload();
|
|
|
|
|
2021-12-30 12:52:08 +01:00
|
|
|
/**
|
|
|
|
* @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();
|
|
|
|
|
2021-12-09 15:02:58 +01:00
|
|
|
/**
|
|
|
|
* @brief Sends packet to the star tracker and reads reply by using the communication
|
|
|
|
* interface
|
2021-12-06 19:36:21 +01:00
|
|
|
*
|
2021-12-21 15:46:09 +01:00
|
|
|
* @param size Size of data beforehand written to the commandBuffer
|
|
|
|
* @param parameter Parameter 2 of trigger event function
|
|
|
|
*
|
2021-12-09 15:02:58 +01:00
|
|
|
* @return RETURN_OK if successful, otherwise RETURN_FAILED
|
|
|
|
*/
|
2021-12-21 15:46:09 +01:00
|
|
|
ReturnValue_t sendAndRead(size_t size, uint32_t parameter);
|
2021-12-09 15:02:58 +01:00
|
|
|
|
|
|
|
/**
|
2021-12-29 20:33:20 +01:00
|
|
|
* @brief Checks the header (type id and status fields) of the action reply
|
2021-12-06 19:36:21 +01:00
|
|
|
*
|
2021-12-09 15:02:58 +01:00
|
|
|
* @return RETURN_OK if reply confirms success of packet transfer, otherwise REUTRN_FAILED
|
2021-12-06 19:36:21 +01:00
|
|
|
*/
|
2021-12-29 20:33:20 +01:00
|
|
|
ReturnValue_t checkActionReply();
|
2021-12-06 19:36:21 +01:00
|
|
|
|
|
|
|
/**
|
2021-12-21 15:46:09 +01:00
|
|
|
* @brief Checks the position field in a star tracker upload/download reply.
|
2021-12-09 15:02:58 +01:00
|
|
|
*
|
|
|
|
* @param expectedPosition Value of expected position
|
2021-12-06 19:36:21 +01:00
|
|
|
*
|
2021-12-09 15:02:58 +01:00
|
|
|
* @return RETURN_OK if received position matches expected position, otherwise RETURN_FAILED
|
2021-12-06 19:36:21 +01:00
|
|
|
*/
|
2021-12-09 15:02:58 +01:00
|
|
|
ReturnValue_t checkReplyPosition(uint32_t expectedPosition);
|
2021-12-11 11:56:47 +01:00
|
|
|
|
2021-12-21 15:46:09 +01:00
|
|
|
/**
|
2021-12-22 16:06:30 +01:00
|
|
|
* @brief Checks the region, address and length value of a flash write or read reply.
|
2021-12-21 15:46:09 +01:00
|
|
|
*
|
|
|
|
* @return RETURN_OK if values match expected values, otherwise appropriate error return
|
|
|
|
* value.
|
|
|
|
*/
|
2021-12-22 16:06:30 +01:00
|
|
|
ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_);
|
2021-12-21 15:46:09 +01:00
|
|
|
|
2021-12-29 20:33:20 +01:00
|
|
|
/**
|
2021-12-30 12:52:08 +01:00
|
|
|
* @brief Checks the reply to the fpga download and upload request
|
2021-12-29 20:33:20 +01:00
|
|
|
*
|
|
|
|
* @param expectedPosition The expected position value in the reply
|
|
|
|
* @param expectedLength The expected length field in the reply
|
|
|
|
*/
|
2021-12-30 12:52:08 +01:00
|
|
|
ReturnValue_t checkFpgaActionReply(uint32_t expectedPosition, uint32_t expectedLength);
|
2021-12-29 20:33:20 +01:00
|
|
|
|
2021-12-11 11:56:47 +01:00
|
|
|
/**
|
|
|
|
* @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);
|
2021-11-30 16:01:02 +01:00
|
|
|
};
|
|
|
|
|
2021-12-21 15:46:09 +01:00
|
|
|
#endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */
|