ns delay between gpio polls solves it
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-03-28 21:45:04 +02:00
parent c474d6ed1d
commit d09b53f6df
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 21 additions and 30 deletions

View File

@ -34,14 +34,18 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) {
return DirectTmSinkIF::IS_BUSY; return DirectTmSinkIF::IS_BUSY;
} }
for (size_t idx = 0; idx < size; idx++) { for (size_t idx = 0; idx < size; idx++) {
if (pollPapbBusySignal(3) == returnvalue::OK) { // This delay is super-important, DO NOT REMOVE!
// Polling the GPIO
nanosleep(&BETWEEN_POLL_DELAY, &remDelay);
if (pollPapbBusySignal(2) == returnvalue::OK) {
*(vcBaseReg + DATA_REG_OFFSET) = static_cast<uint32_t>(data[idx]); *(vcBaseReg + DATA_REG_OFFSET) = static_cast<uint32_t>(data[idx]);
} else { } else {
abortPacketTransfer(); abortPacketTransfer();
return returnvalue::FAILED; return returnvalue::FAILED;
} }
} }
if (pollPapbBusySignal(3) == returnvalue::OK) { nanosleep(&BETWEEN_POLL_DELAY, &remDelay);
if (pollPapbBusySignal(2) == returnvalue::OK) {
completePacketTransfer(); completePacketTransfer();
} else { } else {
abortPacketTransfer(); abortPacketTransfer();

View File

@ -76,8 +76,8 @@ class PapbVcInterface : public VirtualChannelIF {
*/ */
static const int DATA_REG_OFFSET = 256; static const int DATA_REG_OFFSET = 256;
static constexpr long int FIRST_NON_NULL_DELAY_NS = 1000; static constexpr long int FIRST_NON_NULL_DELAY_NS = 10;
static constexpr long int MAX_DELAY_PAPB_POLLING_NS = 4000; static constexpr long int MAX_DELAY_PAPB_POLLING_NS = 40;
LinuxLibgpioIF* gpioComIF = nullptr; LinuxLibgpioIF* gpioComIF = nullptr;
@ -89,6 +89,7 @@ class PapbVcInterface : public VirtualChannelIF {
std::string uioFile; std::string uioFile;
int mapNum = 0; int mapNum = 0;
mutable struct timespec nextDelay = {.tv_sec = 0, .tv_nsec = 0}; mutable struct timespec nextDelay = {.tv_sec = 0, .tv_nsec = 0};
const struct timespec BETWEEN_POLL_DELAY = {.tv_sec = 0, .tv_nsec = 5};
mutable struct timespec remDelay; mutable struct timespec remDelay;
volatile uint32_t* vcBaseReg = nullptr; volatile uint32_t* vcBaseReg = nullptr;
@ -116,7 +117,7 @@ class PapbVcInterface : public VirtualChannelIF {
* *
* @return returnvalue::OK when ready to receive data else PAPB_BUSY. * @return returnvalue::OK when ready to receive data else PAPB_BUSY.
*/ */
ReturnValue_t pollPapbBusySignal(uint32_t maxPollRetries) const; inline ReturnValue_t pollPapbBusySignal(uint32_t maxPollRetries) const;
/** /**
* @brief This function can be used for debugging to check whether there are packets in * @brief This function can be used for debugging to check whether there are packets in

View File

@ -43,15 +43,9 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext), miscStoreContext); stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext), miscStoreContext);
if (not someonesBusy) { if (not someonesBusy) {
TaskFactory::delayTask(100); TaskFactory::delayTask(100);
} else if (someFileWasSwapped) {
TaskFactory::delayTask(20);
} else if (vcBusyDuringDump) { } else if (vcBusyDuringDump) {
// TODO: Might not be necessary
TaskFactory::delayTask(20); TaskFactory::delayTask(20);
} else if (byteFlowControl) {
TaskFactory::delayTask(10);
} else {
// TODO: Lower this as much as possible...
TaskFactory::delayTask(10);
} }
} }
} }

View File

@ -23,30 +23,22 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
} }
bool busy = handleOneStore(storeWithQueue, dumpContext); bool busy = handleOneStore(storeWithQueue, dumpContext);
if (not busy) { if (not busy) {
result = TaskFactory::delayTask(100); TaskFactory::delayTask(100);
delayNotBusy++; delayNotBusy++;
} else if (dumpContext.vcBusyDuringDump) { } else if (dumpContext.vcBusyDuringDump) {
// TODO: Might not be necessary
delaysVcBusyDuringDump++; delaysVcBusyDuringDump++;
result = TaskFactory::delayTask(10); TaskFactory::delayTask(10);
} else if (dumpContext.packetWasDumped and
dumpContext.dumpedBytes - dumpContext.bytesDumpedAtLastDelay >= 2048) {
dumpContext.bytesDumpedAtLastDelay = dumpContext.dumpedBytes;
result = TaskFactory::delayTask(10);
delaysFlowControl++;
} else { } else {
// TODO: Lower this as much as possible...
result = TaskFactory::delayTask(5);
delayHotLoop++; delayHotLoop++;
} }
if ((delaysVcBusyDuringDump + delaysFlowControl + delayNotBusy + delayHotLoop) % 2000000 == 0) { // if ((delaysVcBusyDuringDump + delaysFlowControl + delayNotBusy + delayHotLoop) % 2000 ==
sif::debug << "DLY NBUSY: " << delayNotBusy << std::endl; // 0) {
sif::debug << "DLY FLCTRL: " << delaysFlowControl << std::endl; // sif::debug << "DLY NBUSY: " << delayNotBusy << std::endl;
sif::debug << "DLY BUSYDUMP: " << delaysVcBusyDuringDump << std::endl; // sif::debug << "DLY FLCTRL: " << delaysFlowControl << std::endl;
sif::debug << "DLY HOTLOOP: " << delayHotLoop << std::endl; // sif::debug << "DLY BUSYDUMP: " << delaysVcBusyDuringDump << std::endl;
} // sif::debug << "DLY HOTLOOP: " << delayHotLoop << std::endl;
if (result != returnvalue::OK) { // }
sif::warning << "TmStoreTask: Delay failed" << std::endl;
}
} }
} }