Skip to content

Commit

Permalink
runLoop returns bool - true if that's last call in a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
pkubanek committed Nov 6, 2023
1 parent 8d88473 commit dfdfd89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/cRIO/MPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class MPU : public ModbusBuffer {
*
* @param FPGA fpga used to process MPU commands.
*/
void runLoop(FPGA &fpga);
bool runLoop(FPGA &fpga);

loop_state_t getLoopState() { return _loop_state; }

Expand Down
9 changes: 5 additions & 4 deletions src/LSST/cRIO/MPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ std::vector<uint8_t> MPU::getCommandVector() {
return _commands;
}

void MPU::runLoop(FPGA& fpga) {
bool MPU::runLoop(FPGA& fpga) {
switch (_loop_state) {
case loop_state_t::WRITE:
_loop_next_read = std::chrono::steady_clock::now() + _loop_timeout;
Expand All @@ -278,7 +278,7 @@ void MPU::runLoop(FPGA& fpga) {
if (timedout) {
// there is still time to retrive data, wait for IRQ
if (_loop_next_read > std::chrono::steady_clock::now()) {
return;
return false;
}
auto data = fpga.readMPUFIFO(*this);
clearCommanded();
Expand All @@ -295,11 +295,12 @@ void MPU::runLoop(FPGA& fpga) {
} break;
case loop_state_t::IDLE:
if (_loop_next_read > std::chrono::steady_clock::now()) {
return;
return false;
}
_loop_state = loop_state_t::WRITE;
break;
return true;
}
return false;
}

void MPU::_pushTimeout(uint16_t timeout) {
Expand Down

0 comments on commit dfdfd89

Please sign in to comment.