nonNoise / PyMCP2221A

MCP2221 & MCP2221A work in Python.
MIT License
36 stars 21 forks source link

SMBus write_i2c_block_data error #19

Closed DDubbleDD closed 2 years ago

DDubbleDD commented 2 years ago

I found a problem with the SMBus.py write_i2c_block_data definition. The command self.mcp2221.I2C_Write(addrs,[cmd,vals]) has a problem. Specifically, the parameter [cmd,vals] ends up sending a LIST of LISTS into the I2C_Write function and triggers the error "TypeError: 'list' object cannot be interpreted as an integer."

I changed the code to the following:

    def write_i2c_block_data(self, addrs,cmd,vals):
        vals.insert(0, cmd)  # Insert the CMD into the beginning of the vals LIST.
        self.mcp2221.I2C_Write(addrs,vals)

This fixes the error.

DDubbleDD commented 2 years ago

Fixed in Pull Request #20.