Skip to content

Modbus exception 2 with d.scan() for Sunny Tripower 10 SE #116

Description

@elemakil

I am trying to read out data from my SMA Sunny Tripower 10 SE. I have activated Modbus connection and when I scan the device

import sunspec2.modbus.client as client
d = client.SunSpecModbusClientDeviceTCP(slave_id=126, ipaddr='192.168.1.20', ipport=502)

def progress(msg):
    print(msg)
    return True

d.scan(progress=progress)

The following printout is shown (traceback formatted by ipython):

Scanning model 1
Scanning model 11
Scanning model 12
Scanning model 103
Scanning model 120
Scanning model 121
Scanning model 122
Scanning model 123
Scanning model 64870
Scanning model 160
---------------------------------------------------------------------------
ModbusClientException                     Traceback (most recent call last)
Cell In[4], line 1
----> 1 d.scan(progress=progress)

File ~/sma/venv/lib/python3.11/site-packages/sunspec2/modbus/client.py:280, in SunSpecModbusClientDevice.scan(self, progress, delay, connect, full_model_read)
    276 mid = 0
    277 while model_id != mb.SUNS_END_MODEL_ID:
    278     # read model and model len separately due to some devices not supplying
    279     # count for the end model id
--> 280     model_len_data = self.read(addr + 1, 1)
    281     if model_len_data and len(model_len_data) == 2:
    282         if progress is not None:

File ~/sma/venv/lib/python3.11/site-packages/sunspec2/modbus/client.py:360, in SunSpecModbusClientDeviceTCP.read(self, addr, count, op)
    359 def read(self, addr, count, op=modbus_client.FUNC_READ_HOLDING):
--> 360     return self.client.read(addr, count, op)

File ~/sma/venv/lib/python3.11/site-packages/sunspec2/modbus/modbus.py:720, in ModbusClientTCP.read(self, addr, count, op)
    718 else:
    719     read_count = count
--> 720 data = self._read(addr + read_offset, read_count, op=op)
    722 if data:
    723     resp += data

File ~/sma/venv/lib/python3.11/site-packages/sunspec2/modbus/modbus.py:682, in ModbusClientTCP._read(self, addr, count, op)
    679     self.trace_func(s)
    681 if except_code:
--> 682     raise ModbusClientException('Modbus exception %d: addr: %s count: %s' % (except_code, addr, count))
    684 return resp[(TCP_HDR_LEN + 3):]

ModbusClientException: Modbus exception 2: addr: 40672 count: 1

The general connection seems to work as I can access some models afterwards, e.g.:

Image

I am testing this using python 3.11.6 with sunspec2 version 1.1.5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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