Skip to content

Commit

Permalink
fix: Fixes FW compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ntlhui committed Aug 23, 2024
1 parent 325c82c commit 8332768
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
20 changes: 13 additions & 7 deletions src/rideTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <time.h>


/**
* @brief creates file name for log
* @todo implement RIDE_setFileName
Expand All @@ -33,9 +34,14 @@ static void RIDE_setFileName(system_tick_t startTime)
*/
DeploymentSchedule_t deploymentSchedule[] =
{
{nullptr, nullptr, 0, 0, 0, 0, 0, 0, 0, nullptr, 0, '\0'}
{nullptr, nullptr, 0, 0, 0, 0, nullptr, {0}}
};

RideTask::RideTask() : scheduler(deploymentSchedule)
{

}

/**
* @brief initialize ride task
* Sets LEDs and initializes schedule
Expand All @@ -53,7 +59,8 @@ void RideTask::init()


this->startTime = millis();
SCH_initializeSchedule(deploymentSchedule, this->startTime);

this->scheduler.initializeScheduler();
pSystemDesc->pRecorder->openSession();

}
Expand All @@ -74,10 +81,9 @@ STATES_e RideTask::run(void)

RIDE_setFileName(this->startTime);

uint32_t retval = SCH_getNextEvent(deploymentSchedule,
&pNextEvent,
&nextEventTime,
millis());
SCH_error_e retval = this->scheduler.getNextTask(&pNextEvent,
&nextEventTime,
millis());
//Check if scheduler failed to find nextEvent
if (TASK_SEARCH_FAIL == retval)
{
Expand All @@ -90,7 +96,7 @@ STATES_e RideTask::run(void)
pNextEvent->measure(pNextEvent);
SF_OSAL_printf("|%" PRId32 __NL__, (uint32_t)millis());

pNextEvent->lastMeasurementTime = nextEventTime;
// pNextEvent->lastMeasurementTime = nextEventTime;

if(pSystemDesc->pWaterSensor->getLastStatus() ==
WATER_SENSOR_LOW_STATE)
Expand Down
7 changes: 5 additions & 2 deletions src/rideTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define __RIDE_HPP__
#include "task.hpp"
#include "product.hpp"

#include "scheduler.hpp"

#include <Particle.h>

Expand All @@ -19,6 +19,7 @@
class RideTask : public Task
{
public:
RideTask();
/**
* @brief initialize ride task
* Sets LEDs and initializes schedule
Expand All @@ -36,10 +37,12 @@ class RideTask : public Task
void exit(void);
private:
//! TODO: implement LEDStatus
//LEDStatus ledStatus; //!< manages led behavior
LEDStatus ledStatus; //!< manages led behavior

system_tick_t startTime; /**< start time at initialization */

Scheduler scheduler;

};

#endif
7 changes: 2 additions & 5 deletions src/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ SCH_error_e Scheduler::getNextTask(DeploymentSchedule_t** p_nextEvent,
std::uint32_t* p_nextTime,
std::uint32_t currentTime)
{
std::uint32_t minNextTime = UINT32_MAX;
DeploymentSchedule_t* nextEvent = nullptr;

/*Iterate through each event in the schedule table in reverse order, with
the goal of determining if a lower prioirty task can run before a higher
Expand Down Expand Up @@ -109,7 +107,7 @@ SCH_error_e Scheduler::getNextTask(DeploymentSchedule_t** p_nextEvent,
delay = 0;
}

if (delay >= currentEvent.maxDelay)
if (delay >= (int)currentEvent.maxDelay)
{
//! TODO: send warning
}
Expand All @@ -120,10 +118,9 @@ SCH_error_e Scheduler::getNextTask(DeploymentSchedule_t** p_nextEvent,
will finish overlaps with any task of higher prioirty, we cannot run this
task next. The highest prioirty task will not be checked against other
tasks, so by default that will run*/
int j = 0;
for (int j = 0; (j < idx) && canSet; j++)
{
if (scheduleTable[j].state.nextRunTime < expected_completion)
if ((int)scheduleTable[j].state.nextRunTime < expected_completion)
{
canSet = false;
}
Expand Down

0 comments on commit 8332768

Please sign in to comment.