nmakel / sdm_modbus

Eastron SDM Modbus data collection library
MIT License
45 stars 40 forks source link

can't change holding register #26

Closed bzq-pl closed 1 year ago

bzq-pl commented 1 year ago

Hi,

I'm trying to change few holding registers. When I enter such commands: device.write("display_scroll_timing",10) or device.write("meter_id",10)

in each case I got similar answer: File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sdm_modbus/meter.py", line 309, in write return self._write(self.registers[key], data / self.get_scaling(key)) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sdm_modbus/meter.py", line 277, in _write return self._write_holding_register(address, self._encode_value(data, dtype)) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sdm_modbus/meter.py", line 175, in _write_holding_register return self.client.write_registers(address=address, values=value, unit=self.unit) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pymodbus/client/mixin.py", line 433, in write_registers pdu_req_write.WriteMultipleRegistersRequest( TypeError: WriteMultipleRegistersRequest.init() got multiple values for argument 'unit'

Do you know what I'm doing wrong? Regards Piotr

nmakel commented 1 year ago

Grab the latest update from master, I think @radokristof submitted a pr that fixes this.

bzq-pl commented 1 year ago

I have checked versions of libraries and all dependences and I have downloaded: pip install pyserial==3.4 pip install -U pymodbus==3.0.0 those versions were available for date of last release of sdm_modbus.

now I during wite I have such message... (SDM120 is in setup mode):

import sdm_modbus device = sdm_modbus.SDM120(device="/dev/cu.usbserial-14140", baud=2400, parity="N") device.connected() True device.write("display_scroll_timing",10) 17:39:17 ERROR mixin:498 Please do not use unit=, convert to slave=. ModbusIOException()

reading works well:

device.registers["display_scroll_timing"] (63744, 2, <registerType.HOLDING: 2>, <registerDataType.FLOAT32: 11>, <class 'int'>, 'Display Scroll Timing', 's', 3, 1)

Regards Piotr

nmakel commented 1 year ago

Please grab the latest version of pymodbus. A whole lot was broken during the first 3.x versions.

bzq-pl commented 1 year ago

with version 3.2 of pymodbus I have again error: Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sdm_modbus/meter.py", line 309, in write return self._write(self.registers[key], data / self.get_scaling(key)) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sdm_modbus/meter.py", line 277, in _write return self._write_holding_register(address, self._encode_value(data, dtype)) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sdm_modbus/meter.py", line 175, in _write_holding_register return self.client.write_registers(address=address, values=value, unit=self.unit) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pymodbus/client/mixin.py", line 400, in write_registers pdu_req_write.WriteMultipleRegistersRequest( TypeError: WriteMultipleRegistersRequest.init() got multiple values for argument 'unit'

nmakel commented 1 year ago

You're not using the latest git version. Try that first.

bzq-pl commented 1 year ago

I have moved my project to raspberry with reinstalled Python and now it works!!!