print clcw command
This commit is contained in:
parent
dc0f435dbd
commit
283921cba1
@ -9,14 +9,16 @@
|
|||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include "fsfw/tmtcservices/TmTcMessage.h"
|
#include "fsfw/tmtcservices/TmTcMessage.h"
|
||||||
#include "fsfw/objectmanager/ObjectManager.h"
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
|
#include "fsfw/ipc/QueueFactory.h"
|
||||||
|
|
||||||
|
|
||||||
PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId,
|
PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId,
|
||||||
LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory,
|
LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory,
|
||||||
std::string uioRamMemory, std::string uioRegisters) :
|
std::string uioRamMemory, std::string uioRegisters) :
|
||||||
SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset(
|
SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset(
|
||||||
pdecReset), uioConfigMemory(uioConfigMemory), uioRamMemory(uioRamMemory), uioRegisters(
|
pdecReset), uioConfigMemory(uioConfigMemory), uioRamMemory(uioRamMemory), uioRegisters(
|
||||||
uioRegisters) {
|
uioRegisters), actionHelper(this, nullptr) {
|
||||||
|
commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
PdecHandler::~PdecHandler() {
|
PdecHandler::~PdecHandler() {
|
||||||
@ -62,9 +64,18 @@ ReturnValue_t PdecHandler::initialize() {
|
|||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = actionHelper.initialize(commandQueue);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageQueueId_t PdecHandler::getCommandQueue() const {
|
||||||
|
return commandQueue->getId();
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t PdecHandler::getRegisterAddress() {
|
ReturnValue_t PdecHandler::getRegisterAddress() {
|
||||||
int fd = open(uioRegisters.c_str(), O_RDWR);
|
int fd = open(uioRegisters.c_str(), O_RDWR);
|
||||||
if (fd < 1) {
|
if (fd < 1) {
|
||||||
@ -168,6 +179,8 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) {
|
|||||||
|
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
|
||||||
|
readCommandQueue();
|
||||||
|
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case State::INIT:
|
case State::INIT:
|
||||||
resetFarStatFlag();
|
resetFarStatFlag();
|
||||||
@ -183,7 +196,6 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) {
|
|||||||
if (newTcReceived()) {
|
if (newTcReceived()) {
|
||||||
handleNewTc();
|
handleNewTc();
|
||||||
}
|
}
|
||||||
getClcw();
|
|
||||||
break;
|
break;
|
||||||
case State::WAIT_FOR_RECOVERY:
|
case State::WAIT_FOR_RECOVERY:
|
||||||
break;
|
break;
|
||||||
@ -195,6 +207,24 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) {
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PdecHandler::readCommandQueue(void) {
|
||||||
|
CommandMessage commandMessage;
|
||||||
|
ReturnValue_t result = RETURN_FAILED;
|
||||||
|
|
||||||
|
result = commandQueue->receiveMessage(&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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool PdecHandler::newTcReceived() {
|
bool PdecHandler::newTcReceived() {
|
||||||
uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET);
|
uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET);
|
||||||
|
|
||||||
@ -434,21 +464,12 @@ uint8_t PdecHandler::getOddParity(uint8_t number) {
|
|||||||
return parityBit;
|
return parityBit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdecHandler::getClcw() {
|
uint32_t PdecHandler::getClcw() {
|
||||||
|
return *(registerBaseAddress + PDEC_CLCW_OFFSET);
|
||||||
#if OBSW_DEBUG_PDEC_HANDLER == 1
|
|
||||||
uint32_t clcw = *(registerBaseAddress + PDEC_CLCW_OFFSET);
|
|
||||||
if (debugDivider == 10) {
|
|
||||||
printClcw(clcw);
|
|
||||||
debugDivider = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
debugDivider++;
|
|
||||||
#endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdecHandler::printClcw(uint32_t clcw) {
|
void PdecHandler::printClcw() {
|
||||||
|
uint32_t clcw = getClcw();
|
||||||
uint8_t type = static_cast<uint8_t>((clcw >> 31) & 0x1);
|
uint8_t type = static_cast<uint8_t>((clcw >> 31) & 0x1);
|
||||||
uint8_t versionNo = static_cast<uint8_t>((clcw >> 29) & 0x3);
|
uint8_t versionNo = static_cast<uint8_t>((clcw >> 29) & 0x3);
|
||||||
uint8_t status = static_cast<uint8_t>((clcw >> 26) & 0x7);
|
uint8_t status = static_cast<uint8_t>((clcw >> 26) & 0x7);
|
||||||
@ -487,3 +508,15 @@ void PdecHandler::printClcw(uint32_t clcw) {
|
|||||||
sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex
|
sif::info << std::setw(30) << std::left << "CLCW rep value: " << std::hex
|
||||||
<< "0x" << static_cast<unsigned int>(repValue) << std::endl;
|
<< "0x" << static_cast<unsigned int>(repValue) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
default:
|
||||||
|
return COMMAND_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||||
#include "fsfw/objectmanager/SystemObject.h"
|
#include "fsfw/objectmanager/SystemObject.h"
|
||||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||||
|
#include "fsfw/action/ActionHelper.h"
|
||||||
|
#include "fsfw/action/HasActionsIF.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class controls the PDEC IP Core implemented in the programmable logic of the
|
* @brief This class controls the PDEC IP Core implemented in the programmable logic of the
|
||||||
@ -29,7 +31,10 @@
|
|||||||
*
|
*
|
||||||
* @author J. Meier
|
* @author J. Meier
|
||||||
*/
|
*/
|
||||||
class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF {
|
class PdecHandler : public SystemObject,
|
||||||
|
public ExecutableObjectIF,
|
||||||
|
public HasReturnvaluesIF,
|
||||||
|
public HasActionsIF {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -51,6 +56,21 @@ public:
|
|||||||
|
|
||||||
ReturnValue_t initialize() override;
|
ReturnValue_t initialize() override;
|
||||||
|
|
||||||
|
MessageQueueId_t getCommandQueue() const;
|
||||||
|
|
||||||
|
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||||
|
const uint8_t* data, size_t size) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* brief Returns the 32-bit wide communication link control word (CLCW)
|
||||||
|
*/
|
||||||
|
uint32_t getClcw();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @rief Reads and prints the CLCW. Can be useful for debugging.
|
||||||
|
*/
|
||||||
|
void printClcw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER;
|
static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER;
|
||||||
@ -63,6 +83,9 @@ private:
|
|||||||
static const ReturnValue_t AD_DISCARDED_WAIT = MAKE_RETURN_CODE(0xA4);
|
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 AD_DISCARDED_NS_VS = MAKE_RETURN_CODE(0xA5);
|
||||||
|
|
||||||
|
//! [EXPORT] : [COMMENT] Received action message with unknown action id
|
||||||
|
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xB0);
|
||||||
|
|
||||||
static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6);
|
static const ReturnValue_t NO_REPORT = MAKE_RETURN_CODE(0xA6);
|
||||||
//! Error in version number and reserved A and B fields
|
//! Error in version number and reserved A and B fields
|
||||||
static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7);
|
static const ReturnValue_t ERROR_VERSION_NUMBER = MAKE_RETURN_CODE(0xA7);
|
||||||
@ -88,6 +111,11 @@ private:
|
|||||||
//! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup
|
//! [EXPORT] : [COMMENT] Read invalid FAR from PDEC after startup
|
||||||
static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH);
|
static const Event INVALID_FAR = MAKE_EVENT(2, severity::HIGH);
|
||||||
|
|
||||||
|
static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE;
|
||||||
|
|
||||||
|
// Action IDs
|
||||||
|
static const ActionId_t PRINT_CLCW = 0;
|
||||||
|
|
||||||
static const uint8_t STAT_POSITION = 31;
|
static const uint8_t STAT_POSITION = 31;
|
||||||
static const uint8_t FRAME_ANA_POSITION = 28;
|
static const uint8_t FRAME_ANA_POSITION = 28;
|
||||||
static const uint8_t IREASON_POSITION = 25;
|
static const uint8_t IREASON_POSITION = 25;
|
||||||
@ -182,6 +210,11 @@ private:
|
|||||||
WAIT_FOR_RECOVERY
|
WAIT_FOR_RECOVERY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
* @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.
|
* registers. The register base address will be mapped into the virtual address space.
|
||||||
@ -284,9 +317,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
uint8_t getOddParity(uint8_t number);
|
uint8_t getOddParity(uint8_t number);
|
||||||
|
|
||||||
void getClcw();
|
|
||||||
void printClcw(uint32_t clcw);
|
|
||||||
|
|
||||||
object_id_t tcDestinationId;
|
object_id_t tcDestinationId;
|
||||||
|
|
||||||
AcceptsTelecommandsIF* tcDestination = nullptr;
|
AcceptsTelecommandsIF* tcDestination = nullptr;
|
||||||
@ -309,8 +339,12 @@ private:
|
|||||||
// UIO device file giving access to the PDEC register space
|
// UIO device file giving access to the PDEC register space
|
||||||
std::string uioRegisters;
|
std::string uioRegisters;
|
||||||
|
|
||||||
|
ActionHelper actionHelper;
|
||||||
|
|
||||||
StorageManagerIF* tcStore = nullptr;
|
StorageManagerIF* tcStore = nullptr;
|
||||||
|
|
||||||
|
MessageQueueIF* commandQueue = nullptr;
|
||||||
|
|
||||||
State state = State::INIT;
|
State state = State::INIT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -328,8 +362,6 @@ private:
|
|||||||
uint32_t pdecFar = 0;
|
uint32_t pdecFar = 0;
|
||||||
|
|
||||||
uint8_t tcSegment[TC_SEGMENT_LEN];
|
uint8_t tcSegment[TC_SEGMENT_LEN];
|
||||||
|
|
||||||
uint8_t debugDivider = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* LINUX_OBC_PDECHANDLER_H_ */
|
#endif /* LINUX_OBC_PDECHANDLER_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user