added more sd card stubs
This commit is contained in:
parent
b2c17f12bf
commit
36d2cbfac5
@ -11,4 +11,5 @@ else()
|
|||||||
add_subdirectory(comIF)
|
add_subdirectory(comIF)
|
||||||
add_subdirectory(gpio)
|
add_subdirectory(gpio)
|
||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
|
add_subdirectory(memory)
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_
|
#ifndef BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_
|
||||||
#define BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_
|
#define BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#cmakedefine01 Q7S_SIMPLE_MODE
|
#cmakedefine01 Q7S_SIMPLE_MODE
|
||||||
#define Q7S_ADD_RTD_DEVICES 0
|
#define Q7S_ADD_RTD_DEVICES 0
|
||||||
|
|
||||||
@ -13,4 +15,10 @@
|
|||||||
|
|
||||||
#define Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST 0
|
#define Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST 0
|
||||||
|
|
||||||
|
namespace config {
|
||||||
|
|
||||||
|
static const uint32_t SD_CARD_ACCESS_MUTEX_TIMEOUT = 50;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ */
|
#endif /* BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ */
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
FileSystemTest.cpp
|
FileSystemTest.cpp
|
||||||
|
Q7STestTask.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "FileSystemTest.h"
|
#include "FileSystemTest.h"
|
||||||
|
#include "fsfw/timemanager/Stopwatch.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -7,7 +8,13 @@ FileSystemTest::FileSystemTest() {
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
SdCard sdCard = SdCard::SDC0;
|
SdCard sdCard = SdCard::SDC0;
|
||||||
cout << "SD Card Test for SD card " << static_cast<int>(sdCard) << std::endl;
|
cout << "SD Card Test for SD card " << static_cast<int>(sdCard) << std::endl;
|
||||||
//std::system("echo Hello World");
|
//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() {
|
||||||
|
42
bsp_q7s/boardtest/Q7STestTask.cpp
Normal file
42
bsp_q7s/boardtest/Q7STestTask.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include "Q7STestTask.h"
|
||||||
|
#include "fsfw/timemanager/Stopwatch.h"
|
||||||
|
#include "fsfw/tasks/TaskFactory.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t Q7STestTask::performOneShotAction() {
|
||||||
|
sdCardTests();
|
||||||
|
return TestTask::performOneShotAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Q7STestTask::sdCardTests() {
|
||||||
|
using namespace std;
|
||||||
|
Stopwatch stopwatch;
|
||||||
|
FILE* testFile = popen("q7hw sd info all > /tmp/sd_status.txt", "r");
|
||||||
|
TaskFactory::delayTask(3000);
|
||||||
|
//int result = system();
|
||||||
|
//std::fstream fs(testFile);
|
||||||
|
// Read contents from file
|
||||||
|
char* line = nullptr;
|
||||||
|
size_t len = 0;
|
||||||
|
ssize_t read = getline(&line, &len, testFile);
|
||||||
|
if(read != -1 and line != nullptr) {
|
||||||
|
cout << line << endl;
|
||||||
|
}
|
||||||
|
// c = fgetc(testFile);
|
||||||
|
// while (c != EOF)
|
||||||
|
// {
|
||||||
|
// printf ("%c", c);
|
||||||
|
// c = fgetc(testFile);
|
||||||
|
// }
|
||||||
|
// cout << "Info result " << result << endl;
|
||||||
|
// stopwatch.stop(true);
|
||||||
|
// system("q7hw sd set 0 on > /tmp/sd_set.txt");
|
||||||
|
// stopwatch.stop(true);
|
||||||
|
// system("q7hw sd set 0 off > /tmp/sd_set.txt");
|
||||||
|
// stopwatch.stop(true);
|
||||||
|
}
|
16
bsp_q7s/boardtest/Q7STestTask.h
Normal file
16
bsp_q7s/boardtest/Q7STestTask.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef BSP_Q7S_BOARDTEST_Q7STESTTASK_H_
|
||||||
|
#define BSP_Q7S_BOARDTEST_Q7STESTTASK_H_
|
||||||
|
|
||||||
|
#include "test/testtasks/TestTask.h"
|
||||||
|
|
||||||
|
class Q7STestTask: public TestTask {
|
||||||
|
public:
|
||||||
|
Q7STestTask(object_id_t objectId);
|
||||||
|
private:
|
||||||
|
ReturnValue_t performOneShotAction() override;
|
||||||
|
|
||||||
|
void sdCardTests();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* BSP_Q7S_BOARDTEST_Q7STESTTASK_H_ */
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <bsp_q7s/boardtest/Q7STestTask.h>
|
||||||
#include "ObjectFactory.h"
|
#include "ObjectFactory.h"
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "tmtc/apid.h"
|
#include "tmtc/apid.h"
|
||||||
@ -556,6 +557,11 @@ void ObjectFactory::produce(void* args){
|
|||||||
new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
|
new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);
|
||||||
new UdpTcPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
|
new UdpTcPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
|
||||||
|
|
||||||
|
/* Test Task */
|
||||||
|
#if OBSW_ADD_TEST_CODE == 1
|
||||||
|
new Q7STestTask(objects::TEST_TASK);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if TE0720 == 1 && TEST_LIBGPIOD == 1
|
#if TE0720 == 1 && TEST_LIBGPIOD == 1
|
||||||
/* Configure MIO0 as input */
|
/* Configure MIO0 as input */
|
||||||
GpiodRegular gpioConfigMio0(std::string("gpiochip0"), 0,
|
GpiodRegular gpioConfigMio0(std::string("gpiochip0"), 0,
|
||||||
@ -630,4 +636,5 @@ void ObjectFactory::produce(void* args){
|
|||||||
#if Q7S_ADD_SPI_TEST == 1
|
#if Q7S_ADD_SPI_TEST == 1
|
||||||
new SpiTestClass(objects::SPI_TEST, gpioComIF);
|
new SpiTestClass(objects::SPI_TEST, gpioComIF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
FileSystemManager.cpp
|
FileSystemManager.cpp
|
||||||
SdCardAccess.cpp
|
SdCardAccess.cpp
|
||||||
|
SdCardAccessManager.cpp
|
||||||
)
|
)
|
@ -1,4 +1,22 @@
|
|||||||
#include "SdCardAccess.h"
|
#include "SdCardAccess.h"
|
||||||
|
#include "q7sConfig.h"
|
||||||
|
#include "SdCardAccessManager.h"
|
||||||
|
|
||||||
|
#include "fsfw/ipc/MutexGuard.h"
|
||||||
|
|
||||||
|
SdCardAccess::SdCardAccess(sd::SdCard sdCard) {
|
||||||
|
auto accessManager = SdCardAccessManager::instance();
|
||||||
|
MutexGuard(accessManager->mutex, MutexIF::TimeoutType::WAITING,
|
||||||
|
config::SD_CARD_ACCESS_MUTEX_TIMEOUT);
|
||||||
|
if(accessManager->getSdCardAccessors(sdCard) == 0) {
|
||||||
|
if(sdCard == sd::SdCard::SLOT_0) {
|
||||||
|
std::system("q7hw sd set 0 on");
|
||||||
|
accessManager->activeAccessesSdCard0++;
|
||||||
|
|
||||||
SdCardAccess::SdCardAccess() {
|
}
|
||||||
|
else {
|
||||||
|
std::system("q7hw sd set 1 on");
|
||||||
|
accessManager->activeAccessesSdCard1++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#ifndef BSP_Q7S_MEMORY_SDCARDACCESS_H_
|
#ifndef BSP_Q7S_MEMORY_SDCARDACCESS_H_
|
||||||
#define BSP_Q7S_MEMORY_SDCARDACCESS_H_
|
#define BSP_Q7S_MEMORY_SDCARDACCESS_H_
|
||||||
|
|
||||||
|
#include "definitions.h"
|
||||||
|
|
||||||
class SdCardAccess {
|
class SdCardAccess {
|
||||||
public:
|
public:
|
||||||
SdCardAccess();
|
SdCardAccess(sd::SdCard sdCard);
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
33
bsp_q7s/memory/SdCardAccessManager.cpp
Normal file
33
bsp_q7s/memory/SdCardAccessManager.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include "SdCardAccessManager.h"
|
||||||
|
#include "fsfw/ipc/MutexFactory.h"
|
||||||
|
|
||||||
|
SdCardAccessManager* SdCardAccessManager::factoryInstance = nullptr;
|
||||||
|
|
||||||
|
SdCardAccessManager::~SdCardAccessManager() {
|
||||||
|
MutexFactory::instance()->deleteMutex(mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SdCardAccessManager::create() {
|
||||||
|
if(factoryInstance == nullptr) {
|
||||||
|
factoryInstance = new SdCardAccessManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SdCardAccessManager* SdCardAccessManager::instance() {
|
||||||
|
SdCardAccessManager::create();
|
||||||
|
return SdCardAccessManager::factoryInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
SdCardAccessManager::SdCardAccessManager() {
|
||||||
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SdCardAccessManager::getSdCardAccessors(sd::SdCard sdCard) const {
|
||||||
|
if(sdCard == sd::SdCard::SLOT_0) {
|
||||||
|
return activeAccessesSdCard0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return activeAccessesSdCard1;
|
||||||
|
}
|
||||||
|
}
|
48
bsp_q7s/memory/SdCardAccessManager.h
Normal file
48
bsp_q7s/memory/SdCardAccessManager.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#ifndef BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_
|
||||||
|
#define BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_
|
||||||
|
|
||||||
|
#include "definitions.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
class MutexIF;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This class manages selecting and switching the active SD card, therefore also
|
||||||
|
* managing the redundancy of the SD cards
|
||||||
|
* @details
|
||||||
|
* This class will track the currently active users for a SD card. It is always used by the
|
||||||
|
* SD card access token automatically to get the currently active SD card in a thread safe way-
|
||||||
|
*/
|
||||||
|
class SdCardAccessManager {
|
||||||
|
friend class SdCardAccess;
|
||||||
|
public:
|
||||||
|
virtual ~SdCardAccessManager();
|
||||||
|
|
||||||
|
static void create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the single instance of the SD card manager.
|
||||||
|
*/
|
||||||
|
static SdCardAccessManager* instance();
|
||||||
|
|
||||||
|
sd::SdCard getPreferedSdCard() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current number of SD card users
|
||||||
|
* @param sdCard
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
uint8_t getSdCardAccessors(sd::SdCard sdCard) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SdCardAccessManager();
|
||||||
|
MutexIF* mutex;
|
||||||
|
|
||||||
|
uint8_t activeAccessesSdCard0 = 0;
|
||||||
|
uint8_t activeAccessesSdCard1 = 0;
|
||||||
|
|
||||||
|
static SdCardAccessManager* factoryInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* BSP_Q7S_MEMORY_SDCARDACCESSMANAGER_H_ */
|
15
bsp_q7s/memory/definitions.h
Normal file
15
bsp_q7s/memory/definitions.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef BSP_Q7S_MEMORY_DEFINITIONS_H_
|
||||||
|
#define BSP_Q7S_MEMORY_DEFINITIONS_H_
|
||||||
|
|
||||||
|
namespace sd {
|
||||||
|
|
||||||
|
enum SdCard {
|
||||||
|
SLOT_0,
|
||||||
|
SLOT_1
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* BSP_Q7S_MEMORY_DEFINITIONS_H_ */
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit 38f2f69c784c74cd87a10dce6c968325cf1cb472
|
Subproject commit c2b8507d2947c48e2a2cd19b71640471f436bc5c
|
@ -430,46 +430,56 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) {
|
|||||||
DeviceHandlerIF::PERFORM_OPERATION);
|
DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0,
|
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0,
|
||||||
DeviceHandlerIF::PERFORM_OPERATION);
|
DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
|
#if OBSW_ADD_ACS_BOARD == 1
|
||||||
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0,
|
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0,
|
||||||
DeviceHandlerIF::PERFORM_OPERATION);
|
DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0,
|
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0,
|
||||||
DeviceHandlerIF::PERFORM_OPERATION);
|
DeviceHandlerIF::PERFORM_OPERATION);
|
||||||
|
#endif
|
||||||
|
|
||||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2,
|
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2,
|
||||||
DeviceHandlerIF::SEND_WRITE);
|
DeviceHandlerIF::SEND_WRITE);
|
||||||
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2,
|
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2,
|
||||||
DeviceHandlerIF::SEND_WRITE);
|
DeviceHandlerIF::SEND_WRITE);
|
||||||
|
#if OBSW_ADD_ACS_BOARD == 1
|
||||||
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.2,
|
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.2,
|
||||||
DeviceHandlerIF::SEND_WRITE);
|
DeviceHandlerIF::SEND_WRITE);
|
||||||
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.2,
|
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.2,
|
||||||
DeviceHandlerIF::SEND_WRITE);
|
DeviceHandlerIF::SEND_WRITE);
|
||||||
|
#endif
|
||||||
|
|
||||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4,
|
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4,
|
||||||
DeviceHandlerIF::GET_WRITE);
|
DeviceHandlerIF::GET_WRITE);
|
||||||
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4,
|
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4,
|
||||||
DeviceHandlerIF::GET_WRITE);
|
DeviceHandlerIF::GET_WRITE);
|
||||||
|
#if OBSW_ADD_ACS_BOARD == 1
|
||||||
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.4,
|
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.4,
|
||||||
DeviceHandlerIF::GET_WRITE);
|
DeviceHandlerIF::GET_WRITE);
|
||||||
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.4,
|
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.4,
|
||||||
DeviceHandlerIF::GET_WRITE);
|
DeviceHandlerIF::GET_WRITE);
|
||||||
|
#endif
|
||||||
|
|
||||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6,
|
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6,
|
||||||
DeviceHandlerIF::SEND_READ);
|
DeviceHandlerIF::SEND_READ);
|
||||||
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6,
|
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6,
|
||||||
DeviceHandlerIF::SEND_READ);
|
DeviceHandlerIF::SEND_READ);
|
||||||
|
#if OBSW_ADD_ACS_BOARD == 1
|
||||||
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.6,
|
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.6,
|
||||||
DeviceHandlerIF::SEND_READ);
|
DeviceHandlerIF::SEND_READ);
|
||||||
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.6,
|
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.6,
|
||||||
DeviceHandlerIF::SEND_READ);
|
DeviceHandlerIF::SEND_READ);
|
||||||
|
#endif
|
||||||
|
|
||||||
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8,
|
thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8,
|
||||||
DeviceHandlerIF::GET_READ);
|
DeviceHandlerIF::GET_READ);
|
||||||
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8,
|
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8,
|
||||||
DeviceHandlerIF::GET_READ);
|
DeviceHandlerIF::GET_READ);
|
||||||
|
#if OBSW_ADD_ACS_BOARD == 1
|
||||||
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.8,
|
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.8,
|
||||||
DeviceHandlerIF::GET_READ);
|
DeviceHandlerIF::GET_READ);
|
||||||
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.8,
|
thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.8,
|
||||||
DeviceHandlerIF::GET_READ);
|
DeviceHandlerIF::GET_READ);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) {
|
if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) {
|
||||||
sif::error << "UART PST initialization failed" << std::endl;
|
sif::error << "UART PST initialization failed" << std::endl;
|
||||||
|
@ -83,9 +83,4 @@ void ObjectFactory::produceGenericObjects() {
|
|||||||
pus::PUS_SERVICE_20);
|
pus::PUS_SERVICE_20);
|
||||||
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT,
|
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT,
|
||||||
apid::EIVE_OBSW, pus::PUS_SERVICE_200);
|
apid::EIVE_OBSW, pus::PUS_SERVICE_200);
|
||||||
|
|
||||||
/* Test Device Handler */
|
|
||||||
#if OBSW_ADD_TEST_CODE == 1
|
|
||||||
new TestTask(objects::TEST_TASK);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user