Update Power Modules #287

Merged
meierj merged 18 commits from mueller/update-p60-module-code into develop 2022-08-29 08:27:36 +02:00
5 changed files with 107 additions and 115 deletions
Showing only changes of commit c0a78e6fef - Show all commits

View File

@ -6,6 +6,8 @@
#include "devicedefinitions/GomSpacePackets.h"
#include "devicedefinitions/powerDefinitions.h"
using namespace GOMSPACE;
GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF,
CookieIF* comCookie, FailureIsolationBase* customFdir,
uint16_t maxConfigTableAddress,
@ -76,7 +78,14 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case (GOMSPACE::REQUEST_HK_TABLE): {
result = generateRequestFullHkTableCmd(hkTableReplySize);
result = generateRequestFullTableCmd(GOMSPACE::TableIds::HK, hkTableReplySize);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
break;
}
case (GOMSPACE::REQUEST_CONFIG_TABLE): {
result = generateRequestFullTableCmd(GOMSPACE::TableIds::CONFIG, configTableReplySize);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
@ -214,9 +223,6 @@ ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* comm
<< "action" << std::endl;
return INVALID_ADDRESS;
}
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
uint16_t seq = 0;
uint16_t total = 0;
/* CSP reply only contains the transaction state */
uint16_t querySize = 1;
const uint8_t* parameterPtr = setParamCacher.getParameter();
@ -224,7 +230,7 @@ ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* comm
uint16_t payloadlength = sizeof(address) + parameterSize;
/* Generate command for CspComIF */
CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, total, address,
CspSetParamCommand setParamCmd(querySize, payloadlength, address,
parameterPtr, parameterSize);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
@ -263,7 +269,7 @@ ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* comm
}
/* Get an check table id to read from */
uint8_t tableId = getParamMessage.getTableId();
if (tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID) {
if(not validTableId(tableId)) {
sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter"
" message"
<< std::endl;
@ -271,20 +277,17 @@ ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* comm
}
/* Get and check address */
uint16_t address = getParamMessage.getAddress();
if (address > maxHkTableAddress && tableId == HK_TABLE_ID) {
if (address > maxHkTableAddress and tableId == TableIds::HK) {
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
<< "housekeeping table" << std::endl;
return INVALID_ADDRESS;
}
if (address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID) {
if (address > maxConfigTableAddress and tableId == TableIds::CONFIG) {
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
<< "configuration table" << std::endl;
return INVALID_ADDRESS;
}
uint16_t length = sizeof(address);
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
uint16_t seq = 0;
uint16_t total = 0;
uint8_t parameterSize = getParamMessage.getParameterSize();
if (parameterSize > sizeof(uint32_t)) {
sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter "
@ -294,7 +297,7 @@ ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* comm
uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH;
/* Generate the CSP command to send to the P60 Dock */
CspGetParamCommand getParamCmd(querySize, tableId, length, checksum, seq, total, address);
CspGetParamCommand getParamCmd(querySize, tableId, length, address);
size_t cspPacketLen = 0;
uint8_t* buffer = cspPacket;
result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
@ -396,6 +399,14 @@ ReturnValue_t GomspaceDeviceHandler::initializePduPool(
return RETURN_OK;
}
bool GomspaceDeviceHandler::validTableId(uint8_t id) {
if (id == TableIds::CONFIG or id == TableIds::BOARD_PARAMS or id == TableIds::CALIBRATION or
id == TableIds::HK) {
return true;
}
return false;
}
ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
WatchdogResetCommand watchdogResetCommand;
size_t cspPacketLen = 0;
@ -415,9 +426,9 @@ ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTableReplySize) {
ReturnValue_t GomspaceDeviceHandler::generateRequestFullTableCmd(uint8_t tableId,
uint16_t hkTableReplySize) {
uint16_t querySize = hkTableReplySize;
uint8_t tableId = HK_TABLE_ID;
RequestFullTableCommand requestFullTableCommand(querySize, tableId);
size_t cspPacketLen = 0;
@ -425,7 +436,7 @@ ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTa
ReturnValue_t result = requestFullTableCommand.serialize(
&buffer, &cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "GomspaceDeviceHandler::generateRequestFullHkTableCmd Failed to serialize "
sif::error << "GomspaceDeviceHandler::generateRequestFullTableCmd Failed to serialize "
"full table request command "
<< std::endl;
return result;

View File

@ -52,8 +52,6 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
static const uint8_t MAX_PACKET_LEN = 36;
static const uint8_t PARAM_SET_OK = 1;
static const uint8_t PING_REPLY_SIZE = 2;
static const uint8_t CONFIG_TABLE_ID = 1;
static const uint8_t HK_TABLE_ID = 4;
uint8_t rememberRequestedSize = 0;
uint8_t rememberCommandId = GOMSPACE::NONE;
@ -64,6 +62,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
/** The size of the reply following a full hk table request.*/
uint16_t hkTableReplySize;
uint16_t configTableReplySize;
LocalPoolDataSetBase *hkTableDataset = nullptr;
@ -83,7 +82,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
* @brief The command to generate a request to receive the full housekeeping table is device
* specific. Thus the child has to build this command.
*/
virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize);
virtual ReturnValue_t generateRequestFullTableCmd(uint8_t tableId, uint16_t hkTableSize);
/**
* This command handles printing the HK table to the console. This is useful for debugging
@ -116,6 +115,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
LocalDataPoolManager &poolManager,
std::array<uint8_t, PDU::CHANNELS_LEN> initOutEnb);
static bool validTableId(uint8_t id);
private:
SetParamMessageUnpacker setParamCacher;
/**

View File

@ -7,6 +7,34 @@
#include <fsfw/serialize/SerializeElement.h>
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
class CspParamRequestBase : public SerialLinkedListAdapter<SerializeIF> {
public:
CspParamRequestBase(uint16_t querySize, uint8_t tableId): querySize(querySize), tableId(tableId) {
setLinks();
}
protected:
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&payloadlength);
payloadlength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
SerializeElement<uint16_t> querySize;
SerializeElement<uint8_t> action = GOMSPACE::ParamRequestIds::GET;
SerializeElement<uint8_t> tableId;
// Default value 0: Fetch whole table.
SerializeElement<uint16_t> payloadlength = 0;
SerializeElement<uint16_t> checksum = GOMSPACE::IGNORE_CHECKSUM;
SerializeElement<uint16_t> seq = 0;
SerializeElement<uint16_t> total = 0;
};
/**
* @brief This class can be used to generated the command for the CspComIF
* to reset the watchdog in a gomspace device.
@ -74,46 +102,22 @@ class CspPingCommand : public SerialLinkedListAdapter<SerializeIF> {
* gomspace device but are required for the CspComIF to get the port
* and the size to query.
*/
class CspSetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
class CspSetParamCommand : public CspParamRequestBase {
public:
CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_, uint16_t checksum_,
uint16_t seq_, uint16_t total_, uint16_t addr_, const uint8_t *parameter_,
uint8_t parameterCount_)
: querySize(querySize_),
payloadlength(payloadlength_),
checksum(checksum_),
seq(seq_),
total(total_),
CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_,
uint16_t addr_, const uint8_t *parameter_,
uint8_t parameterCount_, uint8_t tableId = 1)
: CspParamRequestBase(querySize_, tableId),
addr(addr_),
parameter(parameter_, parameterCount_) {
setLinks();
}
private:
CspSetParamCommand(const CspSetParamCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&payloadlength);
payloadlength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
total.setNext(&addr);
addr.setNext(&parameter);
CspParamRequestBase::payloadlength = payloadlength_;
CspParamRequestBase::action = GOMSPACE::ParamRequestIds::SET;
}
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
/* Only a parameter will be set. No data will be queried with this command */
SerializeElement<uint16_t> querySize;
SerializeElement<uint8_t> action = 0xFF; // param set
/* We will never set a parameter in a table other than the configuration
* table */
SerializeElement<uint8_t> tableId = 1;
SerializeElement<uint16_t> payloadlength;
SerializeElement<uint16_t> checksum;
SerializeElement<uint16_t> seq;
SerializeElement<uint16_t> total;
CspSetParamCommand(const CspSetParamCommand &command) = delete;
private:
SerializeElement<uint16_t> addr;
SerializeElement<SerialBufferAdapter<uint8_t>> parameter;
};
@ -126,48 +130,22 @@ class CspSetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
* @note cspPort and querySize only serve as information for the CspComIF
* and will not be transmitted physically to the target device.
*/
class CspGetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
class CspGetParamCommand : public CspParamRequestBase {
public:
/* The size of the header of a gomspace CSP packet. */
static const uint8_t GS_HDR_LENGTH = 12;
CspGetParamCommand(uint16_t querySize_, uint8_t tableId_, uint16_t addresslength_,
uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_)
: querySize(querySize_),
tableId(tableId_),
addresslength(addresslength_),
checksum(checksum_),
seq(seq_),
total(total_),
uint16_t addr_)
: CspParamRequestBase(querySize_, tableId_),
addr(addr_) {
fixedValuesInit();
setLinks();
}
private:
CspGetParamCommand(const CspGetParamCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&addresslength);
addresslength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
total.setNext(&addr);
CspParamRequestBase::tableId = tableId_;
CspParamRequestBase::payloadlength = addresslength_;
}
void fixedValuesInit() { cspPort.entry = GOMSPACE::PARAM_PORT; }
SerializeElement<uint8_t> cspPort;
SerializeElement<uint16_t> querySize; // size of bytes to query
/* Following information will also be physically transmitted to the target
* device*/
SerializeElement<uint8_t> action = 0x00; // get param
SerializeElement<uint8_t> tableId;
SerializeElement<uint16_t> addresslength;
SerializeElement<uint16_t> checksum;
SerializeElement<uint16_t> seq;
SerializeElement<uint16_t> total;
CspGetParamCommand(const CspGetParamCommand &command) = delete;
private:
SerializeElement<uint16_t> addr;
};
@ -179,37 +157,14 @@ class CspGetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
* @note cspPort and querySize only serve as information for the CspComIF
* and will not be transmitted physically to the target device.
*/
class RequestFullTableCommand : public SerialLinkedListAdapter<SerializeIF> {
class RequestFullTableCommand : public CspParamRequestBase {
public:
RequestFullTableCommand(uint16_t querySize_, uint8_t tableId_)
: querySize(querySize_), tableId(tableId_) {
setLinks();
}
: CspParamRequestBase(querySize_, tableId_) {}
RequestFullTableCommand(const RequestFullTableCommand &command) = delete;
private:
RequestFullTableCommand(const RequestFullTableCommand &command);
void setLinks() {
setStart(&cspPort);
cspPort.setNext(&querySize);
querySize.setNext(&action);
action.setNext(&tableId);
tableId.setNext(&addresslength);
addresslength.setNext(&checksum);
checksum.setNext(&seq);
seq.setNext(&total);
}
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
/** Size of bytes to query (size of csp header + size of table) */
SerializeElement<uint16_t> querySize;
/* Following information will also be physically transmitted to the target
* device*/
SerializeElement<uint8_t> action = 0x00; // get param
SerializeElement<uint8_t> tableId;
/* Size of address. Set to 0 to get full table */
SerializeElement<uint16_t> addresslength = 0;
SerializeElement<uint16_t> checksum = GOMSPACE::IGNORE_CHECKSUM;
SerializeElement<uint16_t> seq = 0;
SerializeElement<uint16_t> total = 0;
};
/**

View File

@ -37,12 +37,38 @@ static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t REQUEST_CONFIG_TABLE = 17; //!< [EXPORT] : [COMMAND]
// Not implemented yet
// static const DeviceCommandId_t REQUEST_CALIB_TABLE = 18; //!< [EXPORT] : [COMMAND]
//! [EXPORT] : [COMMAND] Print switch states, voltages and currents to the console
//! For the ACU device, only print voltages and currents of the 6 ACU channels
static const DeviceCommandId_t PRINT_SWITCH_V_I = 32;
static const DeviceCommandId_t PRINT_LATCHUPS = 33;
enum ParamRequestIds: uint8_t {
GET = 0x00,
REPLY = 0x55,
SET = 0xFF,
TABLE_SPEC = 0x44,
// Copy memory slot to memory slot
COPY = 0x77,
// Load from file to slot. Load from primary slot
LOAD = 0x88,
// Load by name(s)
LOAD_FROM_STORE = 0x89,
// Save to primary slot
SAVE = 0x99,
// Save by name(s)
SAVE_TO_STORE = 0x9a
};
enum TableIds: uint8_t {
BOARD_PARAMS = 0,
CONFIG = 1,
CALIBRATION = 2,
HK = 4
};
} // namespace GOMSPACE
namespace P60System {

2
tmtc

@ -1 +1 @@
Subproject commit d19cdfa5663966548918091005c7e9bc912e4041
Subproject commit d61af604fec53b6a0af8d54e7c01792fc9a68790