e-band control commands

This commit is contained in:
Jakob Meier
2022-03-21 16:21:51 +01:00
parent 664670573a
commit bbed4a3b6e
7 changed files with 258 additions and 26 deletions

View File

@ -41,7 +41,7 @@ namespace apid {
static const uint16_t TC_FLASHFOPEN = 0x119;
static const uint16_t TC_FLASHFCLOSE = 0x11A;
static const uint16_t TC_FLASHDELETE = 0x11C;
static const uint16_t TC_DOWLINK_PWR_OFF = 0x124;
static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124;
static const uint16_t TM_MEMORY_READ_REPORT = 0x404;
static const uint16_t ACK_SUCCESS = 0x400;
static const uint16_t ACK_FAILURE = 0x401;
@ -73,7 +73,13 @@ static const size_t MAX_COMMAND_SIZE = SpacePacket::PACKET_MAX_SIZE;
static const size_t MAX_DATA_SIZE = 1016;
/**
* @breif Abstract base class for TC space packet of MPSoC.
* The replay write sequence command has a maximum delay for the execution report which amounts to
* 30 seconds (60 cycles * 0.5 seconds).
*/
static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 60;
/**
* @brief Abstract base class for TC space packet of MPSoC.
*/
class TcBase : public SpacePacket, public HasReturnvaluesIF {
public:
@ -327,6 +333,28 @@ public:
}
};
/**
* @brief Class to build flash write space packet.
*/
class TcFlashWrite : public TcBase {
public:
TcFlashWrite(uint16_t sequenceCount) :
TcBase(apid::TC_FLASHWRITE, sequenceCount) {
}
ReturnValue_t createPacket(uint8_t* writeData, uint32_t writeLen) {
if (writeLen > MAX_DATA_SIZE) {
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
return RETURN_FAILED;
}
std::memcpy(this->getPacketData(), writeData, writeLen);
addCrc();
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
return RETURN_OK;
}
};
/**
* @brief Class to help creation of flash delete command.
*/
@ -341,33 +369,32 @@ public:
ReturnValue_t result = RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
result = addCrc();
if (result != RETURN_OK) {
return result;
}
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
return result;
}
};
/**
* @brief Class to build flash write space packet.
* @brief Class to build replay stop space packet.
*/
class FlashWrite : public TcBase {
class TcReplayStop : public TcBase {
public:
FlashWrite(uint16_t sequenceCount) :
TcBase(apid::TC_FLASHWRITE, sequenceCount) {
TcReplayStop(uint16_t sequenceCount) :
TcBase(apid::TC_REPLAY_STOP, sequenceCount) {
}
ReturnValue_t createPacket(uint8_t* writeData, uint32_t writeLen) {
if (writeLen > MAX_DATA_SIZE) {
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
return RETURN_FAILED;
ReturnValue_t createPacket() {
ReturnValue_t result = RETURN_OK;
result = addCrc();
if (result != RETURN_OK) {
return result;
}
std::memcpy(this->getPacketData(), writeData, writeLen);
addCrc();
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return RETURN_OK;
}
};
@ -391,7 +418,7 @@ protected:
if (result != RETURN_OK) {
return result;
}
result = lengthData(commandData);
result = checkData(*commandData);
if (result != RETURN_OK) {
return result;
}
@ -424,14 +451,14 @@ private:
};
/**
* @brief This class helps to build the replay stop command.
* @brief This class helps to build downlink power on command.
*/
class TcReplayStart: public TcBase {
class TcDownlinkPwrOn: public TcBase {
public:
/**
* @brief Constructor
*/
TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) {
TcDownlinkPwrOn(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_ON, sequenceCount) {
}
protected:
@ -442,7 +469,97 @@ protected:
if (result != RETURN_OK) {
return result;
}
result = lengthData(commandData);
result = modeCheck(*commandData);
if (result != RETURN_OK) {
return result;
}
result = laneRateCheck(*(commandData + 1));
if (result != RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
std::memcpy(this->localData.fields.buffer + commandDataLen, &MAX_AMPLITUDE,
sizeof(MAX_AMPLITUDE));
this->setPacketDataLength(commandDataLen + sizeof(MAX_AMPLITUDE) + CRC_SIZE - 1);
return result;
}
private:
static const uint8_t INTERFACE_ID = CLASS_ID::DWLPWRON_CMD;
//! [EXPORT] : [COMMENT] Received command has invalid JESD mode (valid modes are 0 - 5)
static const ReturnValue_t INVALID_MODE = MAKE_RETURN_CODE(0xE0);
//! [EXPORT] : [COMMENT] Received command has invalid lane rate (valid lane rate are 0 - 9)
static const ReturnValue_t INVALID_LANE_RATE = MAKE_RETURN_CODE(0xE1);
static const size_t COMMAND_DATA_LENGTH = 2;
static const uint8_t MAX_MODE = 5;
static const uint8_t MAX_LANE_RATE = 9;
static const uint16_t MAX_AMPLITUDE = 0;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen != COMMAND_DATA_LENGTH) {
sif::warning << "TcDownlinkPwrOn: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH;
}
return RETURN_OK;
}
ReturnValue_t modeCheck(uint8_t mode) {
if (mode > MAX_MODE) {
sif::warning << "TcDwonlinkPwrOn::modeCheck: Invalid JESD mode" << std::endl;
return INVALID_MODE;
}
return RETURN_OK;
}
ReturnValue_t laneRateCheck(uint8_t laneRate) {
if (laneRate > MAX_LANE_RATE) {
sif::warning << "TcReplayStart::laneRateCheck: Invalid lane rate" << std::endl;
return INVALID_LANE_RATE;
}
return RETURN_OK;
}
};
/**
* @brief Class to build replay stop space packet.
*/
class TcDownlinkPwrOff : public TcBase {
public:
TcDownlinkPwrOff(uint16_t sequenceCount) :
TcBase(apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {
}
ReturnValue_t createPacket() {
ReturnValue_t result = RETURN_OK;
result = addCrc();
if (result != RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return RETURN_OK;
}
};
/**
* @brief This class helps to build the replay start command.
*/
class TcReplayWriteSeq: public TcBase {
public:
/**
* @brief Constructor
*/
TcReplayWriteSeq(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != RETURN_OK) {
return result;
}
@ -451,6 +568,17 @@ protected:
return result;
}
private:
static const size_t USE_DECODING_LENGTH = 1;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen > USE_DECODING_LENGTH + MAX_FILENAME_SIZE) {
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH;
}
return RETURN_OK;
}
};
}