eydam-prototyping / mp_modbus

Modbus Lib for Micropython
MIT License
11 stars 3 forks source link

Doesn't work "as is" with current state of micropython due to bug within interpreter #3

Open mirko opened 1 year ago

mirko commented 1 year ago

This is not a bug in this library, but within the micropython project - and rather a FYI in case others experience the same issue. When trying to use the mp_modbus lib with the current release / master of mpy, I'm encountering the following error:

>>> from mp_modbus_master import modbus_rtu_master
>>> modbus_rtu_master()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/TMP/mp_modbus_master.py", line 513, in __init__
TypeError: unexpected keyword argument 'rtu'
>>>

Respective ticket as part of the micropython project: https://github.com/micropython/micropython/issues/11439

Possible workaround for the moment (thanks to @Jimmo):

diff --git a/mp_modbus_master.py b/mp_modbus_master.py
index 874d44e..c56c3d8 100644
--- a/mp_modbus_master.py
+++ b/mp_modbus_master.py
@@ -510,7 +510,8 @@ class modbus_rtu_master(modbus_master):
             device_addr (int, optional): [description]. Defaults to 1.
         """

-        super(modbus_rtu_master, self).__init__(ms_type="rtu", *args, **kwargs)
+        kwargs['ms_type'] = "rtu"
+        super(modbus_rtu_master, self).__init__(*args, **kwargs)
         self.device_addr = device_addr
         if mp:
             self.baudrate = baudrate
papercodeIN commented 1 year ago

Hi @mirko,

could you please guide how can I install this module in Raspbeery Pi Pico W using Micropython ?

Thanks & Regards.

mirko commented 1 year ago

could you please guide how can I install this module in Raspbeery Pi Pico W using Micropython ?

This ticket is tracking a certain issue which your request seems unrelated to. Apart from that, this is an issue tracker. As I'm not part of this project, I don't know where to direct you with your request, but most likely neither this issue tracker, nor me as a person are the correct addressees - sorry.