Skip to content

Allow multiple unit IDs to be accessed through a single connection #107

@sgryphon

Description

@sgryphon

Some devices, such as a group of multiple SolarEdge systems, can be configured with a single TCP/IP interface, with multiple device Unit IDs linked via Serial connection. The main device acts as a router to the connected devices, based on Unit ID.

The current code of pysunspec2 sets the Unit ID when a client, e.g. SunSpecModbusClientDeviceTCP, is created.

In some cases, a client could simply make multiple TCP/IP connections, each with a different Unit ID, and it should work. However SolarEdge only allow a single TCP/IP connection.

Noting that the Unit ID is actually part of the header of individual messages, it should be possible to use one connection for multiple unit IDs.

e.g. as well as the existing read and write operations, there could be read_unit and write_unit methods, that take an additional parameter for the Unit ID to use, and then pass that through to the connection. Then when doing the actual operations, e.g. _read, the packed struct can use the specified unit_id (or default to the value during construction).

This would allow a client to make a single connection to a SolarEdge device, and then read both the primary Unit ID and any secondary attached Unit IDs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions