Skip to content

Commit

Permalink
ModbusSunSpec: additional networking task
Browse files Browse the repository at this point in the history
  • Loading branch information
pipelka committed Feb 15, 2024
1 parent 40f3897 commit 6eca090
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions include/ModbusSunSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class ModbusSunSpecClass : protected ModbusTCP {

void loop();

void task();

void loopPowerLimit();

bool setLimit(uint64_t serial, uint16_t watts, const char *cause);
Expand All @@ -61,6 +63,8 @@ class ModbusSunSpecClass : protected ModbusTCP {
Limit _limit[INV_MAX_COUNT];

Task _loopTask;

Task _netTask;
};

extern ModbusSunSpecClass ModbusSunSpec;
12 changes: 9 additions & 3 deletions src/ModbusSunSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
ModbusSunSpecClass ModbusSunSpec;

ModbusSunSpecClass::ModbusSunSpecClass()
: _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&ModbusSunSpecClass::loop, this))
: _loopTask(100 * TASK_MILLISECOND, TASK_FOREVER, std::bind(&ModbusSunSpecClass::loop, this))
, _netTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&ModbusSunSpecClass::task, this))
{
}

Expand Down Expand Up @@ -217,6 +218,9 @@ void ModbusSunSpecClass::init(Scheduler& scheduler) {

scheduler.addTask(_loopTask);
_loopTask.enable();

scheduler.addTask(_netTask);
_netTask.enable();
}

void ModbusSunSpecClass::loopPowerLimit() {
Expand Down Expand Up @@ -249,9 +253,11 @@ void ModbusSunSpecClass::loopPowerLimit() {
}
}

void ModbusSunSpecClass::loop() {
task();
void ModbusSunSpecClass::task() {
ModbusTCP::task();
}

void ModbusSunSpecClass::loop() {
const CONFIG_T& config = Configuration.get();
bool allProducing = Datastore.getIsAllEnabledProducing();

Expand Down

0 comments on commit 6eca090

Please sign in to comment.