0

I have some problem with DAC MCP4922 in my Raspberry Pi 2.

I use WebIOPi because this DAC is supported device, but when write in Configuration File (command: sudo nano /etc/webiopi/config ) line:

dac = MCP4922

in [DEVICES] section and when I try start server I see something like this:

2015-08-01 14:21:55 - WebIOPi - ERROR - __init__() takes exactly 4 arguments (3 given)
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/__main__.py", line 75, in <module>
    main(sys.argv)
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.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-armv7l.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-armv7l.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-armv7l.egg/webiopi/devices/analog/mcp492X.py", line 52, in __init__
    MCP492X.__init__(self, chip, 2)
TypeError: __init__() takes exactly 4 arguments (3 given)

I don't have idea what to do.

0

1 Answer 1

0

This is a bug in the WebIOPi project.

In the mcp492X.py module, the MCP492X takes 3 arguments (over and above the default self argument):

class MCP492X(SPI, DAC):
    def __init__(self, chip, channelCount, vref):

but the 2 subclasses in that file do not pass on the vref parameter:

class MCP4921(MCP492X):
    def __init__(self, chip=0, vref=3.3):
        MCP492X.__init__(self, chip, 1)

class MCP4922(MCP492X):
    def __init__(self, chip=0, vref=3.3):
        MCP492X.__init__(self, chip, 2)

You can fix this by simply passing on the vref parameter yourself:

class MCP4921(MCP492X):
    def __init__(self, chip=0, vref=3.3):
        MCP492X.__init__(self, chip, 1, vref)

class MCP4922(MCP492X):
    def __init__(self, chip=0, vref=3.3):
        MCP492X.__init__(self, chip, 2, vref)

You can do this by editing /usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/devices/analog/mcp492X.py directly.

The vref argument was added to fix issue #48, but the developer only added it to the method signatures and forgot to pass on the parameter in the subclasses.

I've filed issue #159 to have the project fix this.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.