Issue #116 [New/open] - Drivers for RTC chips DS1307, DS1337, DS1338, DS3231 and MCP7940 available

Posted by andreas.riegg

Hi,

as already been announced in my WebIOPi driver guide here is the driver code for the chips above. The drivers expose the RTC and (for the chips that have it) also the SDRAM features. This comes along with new hardware abstraction packages for Clock and Memory. To use the drivers two new device subpackage directories have to be created in the WebIOPi Python source directory tree, namely devices/clock and devices/memory.

The files "clock__init__.py", "dsrtc.py" and "mcprtc.py" have to be put into the /clock directory. "clock__init__.py" has there to be renamed to standard "__init__.py".

The files "memory__init__.py" and "filememory.py" have to be put into the /memory directory. "memory__init__.py" has there to be renamed to standard "__init__.py". "filememory.py" contains an experimental driver to store some bytes on disk using standard Python pickle files.

"mananger.py" and "setup.py" as well as "webiopi.js" just replace their current counterparts.

Please do not forget to call "sudo ./setup.sh skip-apt" to make the updates active.

For usage instructions and device parameters look at the comments within the driver sources, I tried to make them informative.

Andreas

Files attached


Comment 1

Posted by andreas.riegg

Hi,

if have updated the drivers and the abstraction code a bit.

The usage instructions remain the same as above, the file "osrtc.py" goes into the /clock directory.

Andreas

Files attached


Comment 2

Posted by andreas.riegg

Just updated webiopi.js so that the problem with "banks" within GPIOPort does not occur any more. This was a remainder of my work for PCA9698 ...

Files attached


Comment 3

Posted by ruud.meesters

Hi,

I tested a DS1307 and encountered the following error:

2015-06-21 15:21:13 - WebIOPi - ERROR - [Errno 16] Device or resource busy Traceback (most recent call last): File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv6l.egg/webiopi/__main__.py", line 75, in main(sys.argv) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv6l.egg/webiopi/__main__.py", line 69, in main server = Server(port=port, configfile=configfile, scriptfile=scriptfile) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv6l.egg/webiopi/server/__init__.py", line 66, in __init__ manager.addDevice(name, driver, args) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv6l.egg/webiopi/devices/manager.py", line 28, in addDevice dev = devClass() File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv6l.egg/webiopi/devices/clock/dsrtc.py", line 190, in __init__ DSclock.__init__(self, control) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv6l.egg/webiopi/devices/clock/dsrtc.py", line 66, in __init__ I2C.__init__(self, 0x68) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv6l.egg/webiopi/devices/i2c.py", line 54, in __init__ if fcntl.ioctl(self.fd, I2C_SLAVE, self.slave): IOError: [Errno 16] Device or resource busy

Any suggestions?


Comment 4

Posted by ruud.meesters

Solved: i2cdetect showed UU for the device. I ran "echo 0x68 > /sys/class/i2c-adapter/i2c-1/delete_device" to revert it back to 68. Now it works fine.