str image loader wip
This commit is contained in:
parent
1affc1e1d3
commit
8c649b3e70
@ -168,13 +168,13 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) {
|
||||
#if BOARD_TE0720 == 0
|
||||
// Check if file is stored on SD card and if associated SD card is mounted
|
||||
if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) {
|
||||
if (!isSdCardMounted(sd::SLOT_0)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "PlocUpdater::getImageLocation: SD card 0 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
}
|
||||
}
|
||||
else if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) {
|
||||
if (!isSdCardMounted(sd::SLOT_0)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "PlocUpdater::getImageLocation: SD card 1 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
}
|
||||
@ -193,37 +193,6 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
#if BOARD_TE0720 == 0
|
||||
bool PlocUpdater::isSdCardMounted(sd::SdCard sdCard) {
|
||||
SdCardManager::SdStatePair active;
|
||||
ReturnValue_t result = sdcMan->getSdCardActiveStatus(active);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocUpdater::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 << "PlocUpdater::isSdCardMounted: Unknown SD card specified" << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif /* #if BOARD_TE0720 == 0 */
|
||||
|
||||
void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId,
|
||||
uint8_t step) {
|
||||
}
|
||||
|
@ -174,13 +174,6 @@ private:
|
||||
*/
|
||||
void commandUpdateVerify();
|
||||
|
||||
#if BOARD_TE0720 == 0
|
||||
/**
|
||||
* @brief Checks whether the SD card to read from is mounted or not.
|
||||
*/
|
||||
bool isSdCardMounted(sd::SdCard sdCard);
|
||||
#endif
|
||||
|
||||
void calcImageCrc();
|
||||
|
||||
void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet);
|
||||
|
75
bsp_q7s/devices/StrImageLoader.cpp
Normal file
75
bsp_q7s/devices/StrImageLoader.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include "StrImageLoader.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
StrImageLoader::StrImageLoader(object_id_t objectId) {
|
||||
|
||||
}
|
||||
|
||||
StrImageLoader::~StrImageLoader() {
|
||||
}
|
||||
|
||||
ReturnValue_t StrImageLoader::initialize() {
|
||||
sdcMan = SdCardManager::instance();
|
||||
if (sdcMan == nullptr) {
|
||||
sif::warning << "StrImageLoader::initialize: Invalid SD Card Manager" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t StrImageLoader::performOperation(uint8_t operationCode) {
|
||||
semaphore.acquire();
|
||||
while(true) {
|
||||
switch(internalState) {
|
||||
case InternalState::IDLE:
|
||||
semaphore.acquire();
|
||||
break;
|
||||
case InternalState::UPLOAD_IMAGE:
|
||||
uploadImage();
|
||||
break;
|
||||
case InternalState::DOWNLOAD_IMAGE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StrImageLoader::setComIF(DeviceCommunicationIF* communicationInterface_) {
|
||||
communicationInterface = communicationInterface_;
|
||||
}
|
||||
|
||||
void StrImageLoader::setComCookie(CookieIF* comCookie_) {
|
||||
comCookie = comCookie_;
|
||||
}
|
||||
|
||||
ReturnValue_t StrImageLoader::startImageUpload(std::string image) {
|
||||
|
||||
//TODO: Use string part not data pointer
|
||||
// Check if file is stored on SD card and if associated SD card is mounted
|
||||
if (image.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT))
|
||||
== std::string(SdCardManager::SD_0_MOUNT_POINT)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "StrImageLoader::getImageLocation: SD card 0 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
}
|
||||
} else if (image.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT))
|
||||
== std::string(SdCardManager::SD_1_MOUNT_POINT)) {
|
||||
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
|
||||
sif::warning << "StrImageLoader::getImageLocation: SD card 1 not mounted" << std::endl;
|
||||
return SD_NOT_MOUNTED;
|
||||
}
|
||||
}
|
||||
|
||||
uploadImage = image;
|
||||
|
||||
if(not std::filesystem::exists(uploadImage)) {
|
||||
return FILE_NOT_EXISTS;
|
||||
}
|
||||
|
||||
internalState = InternalState::UPLOAD_IMAGE;
|
||||
|
||||
semaphore.release();
|
||||
}
|
||||
|
||||
ReturnValue_t StrImageLoader::uploadImage() {
|
||||
|
||||
}
|
||||
|
56
bsp_q7s/devices/StrImageLoader.h
Normal file
56
bsp_q7s/devices/StrImageLoader.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef BSP_Q7S_DEVICES_STRIMAGELOADER_H_
|
||||
#define BSP_Q7S_DEVICES_STRIMAGELOADER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "fsfw/osal/linux/BinarySemaphore.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
|
||||
/**
|
||||
* @brief An object of this class runs in a separate task and is responsible for uploading and
|
||||
* downloading images to/from the star tracker. This is required because uploading and
|
||||
* downloading via the star tracker handler takes a lot of time because each upload or
|
||||
* download packet can transport a maximum of 1024 bytes.
|
||||
*/
|
||||
class StrImageLoader: public SystemObject, public ExecutableObjectIF {
|
||||
public:
|
||||
StrImageLoader(object_id_t objectId);
|
||||
virtual ~StrImageLoader();
|
||||
|
||||
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
|
||||
void setComIF(DeviceCommunicationIF* communicationInterface_);
|
||||
void setComCookie(CookieIF* comCookie_);
|
||||
|
||||
private:
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::STR_IMG_LOADER;
|
||||
|
||||
//! [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);
|
||||
|
||||
enum class InternalState {
|
||||
IDLE,
|
||||
UPLOAD_IMAGE,
|
||||
DOWNLOAD_IMAGE
|
||||
};
|
||||
|
||||
InternalState internalState = InternalState::IDLE;
|
||||
|
||||
BinarySemaphore semaphore;
|
||||
|
||||
// Absolute path and name to image to upload
|
||||
std::string uploadImage;
|
||||
|
||||
SdCardManager* sdcMan = nullptr;
|
||||
|
||||
/**
|
||||
* Communication object responsible for low level access of star tracker
|
||||
* Must be set by star tracker handler
|
||||
*/
|
||||
DeviceCommunicationIF * communicationInterface = nullptr;
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_STRIMAGELOADER_H_ */
|
@ -455,3 +455,33 @@ void SdCardManager::setPrintCommandOutput(bool print) {
|
||||
|
||||
}
|
||||
|
||||
bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) {
|
||||
SdCardManager::SdStatePair active;
|
||||
ReturnValue_t result = sdcMan->getSdCardActiveStatus(active);
|
||||
if (result != 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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -195,6 +195,15 @@ public:
|
||||
|
||||
void setBlocking(bool blocking);
|
||||
void setPrintCommandOutput(bool print);
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
@ -19,7 +19,7 @@ enum commonClassIds: uint8_t {
|
||||
CCSDS_IP_CORE_BRIDGE, //IPCI
|
||||
PTME, //PTME
|
||||
PLOC_UPDATER, //PLUD
|
||||
STR_IMG_HELPER, //STRIMGH
|
||||
STR_IMG_LOADER, //STRIMGL
|
||||
GOM_SPACE_HANDLER, //GOMS
|
||||
PLOC_MEMORY_DUMPER, //PLMEMDUMP
|
||||
PDEC_HANDLER, //PDEC
|
||||
|
@ -10,16 +10,27 @@ extern "C" {
|
||||
}
|
||||
|
||||
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF * comCookie) :
|
||||
CookieIF * comCookie, StrImageLoader* strImageLoader) :
|
||||
DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this), powerSet(
|
||||
this), interfaceSet(this), timeSet(this), solutionSet(this) {
|
||||
if (comCookie == NULL) {
|
||||
this), interfaceSet(this), timeSet(this), solutionSet(this), strImageLoader(
|
||||
strImageLoader) {
|
||||
if (comCookie == nullptr) {
|
||||
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
|
||||
}
|
||||
if (strImageLoader == nullptr) {
|
||||
sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl;
|
||||
}
|
||||
slipInit();
|
||||
}
|
||||
|
||||
StarTrackerHandler::~StarTrackerHandler() {
|
||||
DeviceHandlerBase::initialize();
|
||||
strImageLoader->setComIF(communicationInterface);
|
||||
strImageLoader->setComCookie(comCookie);
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::initialize() {
|
||||
|
||||
}
|
||||
|
||||
void StarTrackerHandler::doStartUp() {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <mission/devices/devicedefinitions/StarTrackerDefinitions.h>
|
||||
#include <thirdparty/arcsec_star_tracker/common/SLIP.h>
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <bsp_q7s/devices/StrImageLoader.h>
|
||||
|
||||
/**
|
||||
* @brief This is the device handler for the star tracker from arcsec.
|
||||
@ -28,9 +29,12 @@ public:
|
||||
* @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);
|
||||
StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie,
|
||||
StrImageLoader* strImageLoader);
|
||||
virtual ~StarTrackerHandler();
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
protected:
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
@ -106,6 +110,9 @@ private:
|
||||
static const MutexIF::TimeoutType TIMEOUT_TYPE= MutexIF::TimeoutType::WAITING;
|
||||
static const uint32_t MUTEX_TIMEOUT = 20;
|
||||
|
||||
// Pointer to object responsible for uploading and downloading images to/from the star tracker
|
||||
StrImageLoader* strImageLoader = nullptr;
|
||||
|
||||
StarTracker::TemperatureSet temperatureSet;
|
||||
StarTracker::VersionSet versionSet;
|
||||
StarTracker::PowerSet powerSet;
|
||||
|
Loading…
Reference in New Issue
Block a user