i2cdevice-python
i2cdevice-python copied to clipboard
TypeError
This afternoon I successfully finished a port of the combo: i2cdevice-python and rv3028-python for use with a RPi Pico mounted on a Pimoroni 'pico explorer pack' on which also stacked a rv3028 breakout.
The only problem left is the fact that there occurs the following error in i2cdevice/__init__.py file, line 174 (class Device.__init__()). self.__dict__[register.name] = _RegisterProxy(self, register)
For the moment I put this line 'out of service' by commenting it out. For the normal get/set date and time functions this 'being out of service' of this line looks not to create problems. However: this line was there for a reason, isn't it? Any advice is welcome!
I'm running into this too - maybe the __dict__ signature changed or something? I haven't looked into it yet. _RegisterProxy explains why it's there:
class _RegisterProxy(object):
"""Register Proxy
This proxy catches lookups against non existent get_fieldname and set_fieldname methods
and converts them into calls against the device's get_field and set_field methods with
the appropriate options.
This means device.register.set_field(value) and device.register.get_field(value) will work
and also transparently update the underlying device without the register or field objects
having to know anything about how data is written/read/stored.
"""
I can't remember the exact motivation behind this eldritch horror, but I don't believe I use device.register.set_field() anywhere in any library based on i2c-device.
Presumably I wanted device.some_settings_register.set_field(1) to work, but I seem to exclusively use the pattern:
device.set("REGISTER", key=value, key2=value2)
I would be delighted to remove this ghastly abomination and patch any libraries that show otherwise. Sometimes simpler is better, and trying to do weird dictionary lookup catching nonsense liks this is just a result of nobody telling me when to stop.
I'm on board with that! Do you want to remove it, or I can open a PR?
Feel free to open a PR- though I’m going to have to do some careful inspection of our i2c-device based libraries to make sure I’m not wrong 😬
Thank you gentlemen for giving your precious time to this! Btw the script with the Pimoroni RTC breakout works perfect. Even having it left without electricity for weeks, it keeps time quit exactly.