Skip to content

Alternative to Full Static Alocation when modbus tcp devices are unknown and can be dynamically added/deleted #5

@cosmicKev

Description

@cosmicKev

Hey, first of all great project! This is way better than esp-modbus which is really cumbersome to understand and even work due to so much abstraction.

Kudos to make all this statically allocated. I wonder if you are open to suggestions and give some thinking on my following suggestions.

Problem

Im building an "extension" around you project to manage Modbus devices. But i'm struggling because of the xTaskCreateStatic, the StaticTask needs to be stored in DRAM, but the buffer can be placed on PSRAM (whcih is the usecase i need)

Image

The idea is having a ModbusHub, where the user can add devices in which will then create "nodes" that at the moment will represent logically a Client. The node is responsible to create the ModbusHal / Interface / Client for each node. (feedback is appreciated btw)
Peharps i dont need a task for each Node but a single task for the Hub to sweep through all nodes and make async requests.

Each node will then use its its own task to poll through the devices associated to that node client and make requests queued in the ModbusDevice itself.

Note: Im using PSRAM this is the only reason why this ModbusHub would even work because atm, since i only have around 50K left on IRAM. The application has a full-fledge webapp with devices management and such.

Solution

  • Statically allocate up to a maximum of 10 clients (HAL/Interface/C)
    • Requires some Task Management system based on 10 task pools where initialization would get the data from.
  • Allow some hooks to use Mallocs.
    • Would allow the usage of heap but also Memory Pools. In my case i divide the system into memory pools big enough so i can monitor each chunk of the pool without the heap corruption.
  • Allow task handler to be passed to client and Hal and would then be created outside the EzModbus

I can contribute with any of this approaches, but would like some input from you since i don't want to waste my time in something that might not be accepted.

On another note:

  • I have a very problematic Modbus TCP device that at some point just disconnects and requires a full restart of the websocket. Have you consider a restart procedure for when the modbus is disconnected? I do get that isReady() = false. Just wondering.

Kind regards
Kevin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions