Skip to content

Some variables are class descriptors instead of instance variables #38

Open
@ilario

Description

@ilario

I am using 18 INA219 boards in parallel using 3 PCA9548 multiplexers and the threading Python package, and I am running triggered measurements.

So I create a few instances of the INA219 class and then I send triggers to them, check when the measurements are ready and fetch the measurement data.

The problem I observed is that conversion_ready is a class variable, as defined here outside of the __init__ function:

conversion_ready = ROBit(_REG_BUSVOLTAGE, 1, 2, False)

So the value will not be instance-specific and all the INA219 objects will share the same values for conversion_ready. Clearly, this is a problem for me.

In the same way, I suspect I can have the same issue also with the other data I acquire from the INA219 boards, no?

For example, also the bus_voltage property relies on the raw_bus_voltage class variable and the current property relies on the raw_current class variable. Should I expect the same issue also for these?

raw_bus_voltage = ROBits(13, _REG_BUSVOLTAGE, 3, 2, False)
conversion_ready = ROBit(_REG_BUSVOLTAGE, 1, 2, False)
overflow = ROBit(_REG_BUSVOLTAGE, 0, 2, False)
# power and current registers
raw_power = ROUnaryStruct(_REG_POWER, ">H")
raw_current = ROUnaryStruct(_REG_CURRENT, ">h")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions