some tweaks for busy handling #500

Merged
muellerr merged 28 commits from tweak_papb_busy_polling into develop 2023-03-24 14:15:01 +01:00
9 changed files with 70 additions and 44 deletions
Showing only changes of commit 493f89e0cb - Show all commits

2
fsfw

@ -1 +1 @@
Subproject commit 227524a21da755d125bcb1a5ff67bcbc452f8cf9 Subproject commit 33ac395072f0145b6e80e12deae978a5e0432f08

View File

@ -1,5 +1,6 @@
#include <fsfw_hal/linux/uio/UioMapper.h> #include <fsfw_hal/linux/uio/UioMapper.h>
#include <linux/ipcore/PapbVcInterface.h> #include <linux/ipcore/PapbVcInterface.h>
#include <unistd.h>
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
@ -15,7 +16,13 @@ PapbVcInterface::~PapbVcInterface() {}
ReturnValue_t PapbVcInterface::initialize() { ReturnValue_t PapbVcInterface::initialize() {
UioMapper uioMapper(uioFile, mapNum); UioMapper uioMapper(uioFile, mapNum);
return uioMapper.getMappedAdress(&vcBaseReg, UioMapper::Permissions::WRITE_ONLY); uint32_t* baseReg;
ReturnValue_t result = uioMapper.getMappedAdress(&baseReg, UioMapper::Permissions::WRITE_ONLY);
if (result != returnvalue::OK) {
return result;
}
vcBaseReg = baseReg;
return returnvalue::OK;
} }
ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) {
@ -24,27 +31,27 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) {
} }
for (size_t idx = 0; idx < size; idx++) { for (size_t idx = 0; idx < size; idx++) {
if (pollPapbBusySignal() == returnvalue::OK) { if (pollPapbBusySignal() == returnvalue::OK) {
*(vcBaseReg + DATA_REG_OFFSET) = static_cast<uint32_t>(*(data + idx)); *(vcBaseReg + DATA_REG_OFFSET) = static_cast<uint32_t>(data[idx]);
} else { } else {
sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size << " data" abortPacketTransfer();
<< std::endl; return DirectTmSinkIF::IS_BUSY;
return returnvalue::FAILED;
} }
} }
if (pollPapbBusySignal() == returnvalue::OK) { if (pollPapbBusySignal() == returnvalue::OK) {
endPacketTransfer(); completePacketTransfer();
} }
return returnvalue::OK; return returnvalue::OK;
} }
void PapbVcInterface::startPacketTransfer() { *vcBaseReg = CONFIG_START; } void PapbVcInterface::startPacketTransfer() { *vcBaseReg = CONFIG_START; }
void PapbVcInterface::endPacketTransfer() { *vcBaseReg = CONFIG_END; } void PapbVcInterface::completePacketTransfer() { *vcBaseReg = CONFIG_END; }
ReturnValue_t PapbVcInterface::pollPapbBusySignal() const { ReturnValue_t PapbVcInterface::pollPapbBusySignal() const {
gpio::Levels papbBusyState = gpio::Levels::LOW; gpio::Levels papbBusyState = gpio::Levels::LOW;
ReturnValue_t result = returnvalue::OK; ReturnValue_t result;
uint32_t busyIdx = 0; uint32_t busyIdx = 0;
uint32_t delayCount = 0;
while (true) { while (true) {
/** Check if PAPB interface is ready to receive data */ /** Check if PAPB interface is ready to receive data */
@ -57,12 +64,17 @@ ReturnValue_t PapbVcInterface::pollPapbBusySignal() const {
if (papbBusyState == gpio::Levels::HIGH) { if (papbBusyState == gpio::Levels::HIGH) {
return returnvalue::OK; return returnvalue::OK;
} }
if (busyIdx == 100) { if (busyIdx == 3) {
usleep(100);
busyIdx = 0;
delayCount += 1;
continue;
}
if (delayCount == 1000) {
return PAPB_BUSY; return PAPB_BUSY;
} }
busyIdx++; busyIdx++;
} }
return returnvalue::OK; return returnvalue::OK;
} }
@ -104,3 +116,5 @@ ReturnValue_t PapbVcInterface::sendTestFrame() {
return returnvalue::OK; return returnvalue::OK;
} }
void PapbVcInterface::abortPacketTransfer() { *vcBaseReg = CONFIG_ABORT; }

View File

@ -51,16 +51,21 @@ class PapbVcInterface : public VirtualChannelIF {
/** /**
* Configuration bits: * Configuration bits:
* bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00
* bit[2]: Set this bit to 1 to abort a transfered packet * bit[2]: Set this bit to 1 to abort a transferred packet
* bit[3]: Signals to VcInterface the start of a new telemetry packet * bit[3]: Signals to VcInterface the start of a new telemetry packet
*/ */
static const uint32_t CONFIG_START = 0x8; static constexpr uint32_t CONFIG_START = 0b00001000;
/**
* Abort a transferred packet.
*/
static constexpr uint32_t CONFIG_ABORT = 0b00000100;
/** /**
* Writing this word to the VcInterface base address signals to the virtual channel interface * Writing this word to the VcInterface base address signals to the virtual channel interface
* that a complete tm packet has been transferred. * that a complete tm packet has been transferred.
*/ */
static const uint32_t CONFIG_END = 0x0; static constexpr uint32_t CONFIG_END = 0x0;
/** /**
* Writing to this offset within the memory space of a virtual channel will insert data for * Writing to this offset within the memory space of a virtual channel will insert data for
@ -79,7 +84,7 @@ class PapbVcInterface : public VirtualChannelIF {
std::string uioFile; std::string uioFile;
int mapNum = 0; int mapNum = 0;
uint32_t* vcBaseReg = nullptr; volatile uint32_t* vcBaseReg = nullptr;
uint32_t vcOffset = 0; uint32_t vcOffset = 0;
@ -89,11 +94,13 @@ class PapbVcInterface : public VirtualChannelIF {
*/ */
void startPacketTransfer(); void startPacketTransfer();
void abortPacketTransfer();
/** /**
* @brief This function sends the config byte to the virtual channel interface of the PTME * @brief This function sends the config byte to the virtual channel interface of the PTME
* IP Core to signal the end of a packet transfer. * IP Core to signal the end of a packet transfer.
*/ */
void endPacketTransfer(); void completePacketTransfer();
/** /**
* @brief This function reads the papb busy signal indicating whether the virtual channel * @brief This function reads the papb busy signal indicating whether the virtual channel

View File

@ -39,7 +39,6 @@ ReturnValue_t CcsdsIpCoreHandler::performOperation(uint8_t operationCode) {
} }
ReturnValue_t CcsdsIpCoreHandler::initialize() { ReturnValue_t CcsdsIpCoreHandler::initialize() {
AcceptsTelecommandsIF* tcDistributor = AcceptsTelecommandsIF* tcDistributor =
ObjectManager::instance()->get<AcceptsTelecommandsIF>(tcDestination); ObjectManager::instance()->get<AcceptsTelecommandsIF>(tcDestination);
if (tcDistributor == nullptr) { if (tcDistributor == nullptr) {

View File

@ -153,7 +153,7 @@ class CcsdsIpCoreHandler : public SystemObject,
PtmeConfig& ptmeConfig; PtmeConfig& ptmeConfig;
PtmeGpios ptmeGpios; PtmeGpios ptmeGpios;
// BAT priority bit on by default to enable priority selection mode for the PTME. // BAT priority bit on by default to enable priority selection mode for the PTME.
uint8_t batPriorityParam = 1; uint8_t batPriorityParam = 0;
bool updateBatPriorityOnTxOff = false; bool updateBatPriorityOnTxOff = false;
GpioIF* gpioIF = nullptr; GpioIF* gpioIF = nullptr;

View File

@ -34,8 +34,11 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
if (not someonesBusy) { if (not someonesBusy) {
TaskFactory::delayTask(40); TaskFactory::delayTask(40);
} else if (someFileWasSwapped and graceDelayDuringDumping.hasTimedOut()) { } else if (someFileWasSwapped and graceDelayDuringDumping.hasTimedOut()) {
TaskFactory::delayTask(2); if (someFileWasSwapped) {
graceDelayDuringDumping.resetTimer(); TaskFactory::delayTask(1);
}
// TaskFactory::delayTask(2);
// graceDelayDuringDumping.resetTimer();
} }
} }
} }

View File

@ -19,10 +19,13 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
if (not busy) { if (not busy) {
TaskFactory::delayTask(40); TaskFactory::delayTask(40);
} else { } else {
if (fileHasSwapped and graceDelayDuringDumping.hasTimedOut()) { if (fileHasSwapped) {
TaskFactory::delayTask(2); TaskFactory::delayTask(1);
graceDelayDuringDumping.resetTimer();
} }
// if (fileHasSwapped and graceDelayDuringDumping.hasTimedOut()) {
// TaskFactory::delayTask(2);
// graceDelayDuringDumping.resetTimer();
// }
} }
} }
} }

View File

@ -216,7 +216,7 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() {
sif::error << "PersistentTmStore: Could not retrieve file size: " << e.message() << std::endl; sif::error << "PersistentTmStore: Could not retrieve file size: " << e.message() << std::endl;
continue; continue;
} }
//sif::debug << "Path: " << dumpParams.dirEntry.path() << std::endl; // sif::debug << "Path: " << dumpParams.dirEntry.path() << std::endl;
// Can't even read CCSDS header. // Can't even read CCSDS header.
if (dumpParams.fileSize <= 6) { if (dumpParams.fileSize <= 6) {

View File

@ -25,27 +25,27 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store,
// Dump TMs when applicable // Dump TMs when applicable
if (store.getState() == PersistentTmStore::State::DUMPING) { if (store.getState() == PersistentTmStore::State::DUMPING) {
size_t dumpedLen = 0; size_t dumpedLen = 0;
// if (not channel.isBusy()) { if (not channel.isBusy()) {
tmSinkBusyCd.resetTimer(); tmSinkBusyCd.resetTimer();
result = store.dumpNextPacket(channel, dumpedLen, fileHasSwapped); result = store.dumpNextPacket(channel, dumpedLen, fileHasSwapped);
if (result == DirectTmSinkIF::IS_BUSY) { if (result == DirectTmSinkIF::IS_BUSY) {
sif::warning << "PersistentTmStore: PAPB was too busy for dump" << std::endl; sif::warning << "PersistentTmStore: PAPB was too busy for dump" << std::endl;
}
if ((result == PersistentTmStore::DUMP_DONE or result == returnvalue::OK) and dumpedLen > 0) {
dumpContext.dumpedBytes += dumpedLen;
dumpContext.numberOfDumpedPackets += 1;
}
if (result == PersistentTmStore::DUMP_DONE) {
uint32_t startTime;
uint32_t endTime;
store.getStartAndEndTimeCurrentOrLastDump(startTime, endTime);
triggerEvent(dumpContext.eventIfDone, dumpContext.numberOfDumpedPackets,
dumpContext.dumpedBytes);
dumpsPerformed = true;
} else if (result == returnvalue::OK) {
dumpsPerformed = true;
}
} }
if ((result == PersistentTmStore::DUMP_DONE or result == returnvalue::OK) and dumpedLen > 0) {
dumpContext.dumpedBytes += dumpedLen;
dumpContext.numberOfDumpedPackets += 1;
}
if (result == PersistentTmStore::DUMP_DONE) {
uint32_t startTime;
uint32_t endTime;
store.getStartAndEndTimeCurrentOrLastDump(startTime, endTime);
triggerEvent(dumpContext.eventIfDone, dumpContext.numberOfDumpedPackets,
dumpContext.dumpedBytes);
dumpsPerformed = true;
} else if (result == returnvalue::OK) {
dumpsPerformed = true;
}
//}
if (cancelDumpCd.hasTimedOut() or tmSinkBusyCd.hasTimedOut()) { if (cancelDumpCd.hasTimedOut() or tmSinkBusyCd.hasTimedOut()) {
triggerEvent(persTmStore::DUMP_WAS_CANCELLED, store.getObjectId()); triggerEvent(persTmStore::DUMP_WAS_CANCELLED, store.getObjectId());
store.cancelDump(); store.cancelDump();