Skip to content
/ Riden Public

get* functions actually physically re-read registers if bulk read values were 0 #6

@zalexua

Description

@zalexua

Add debug (2ndline) to this function:

    def read(self, register: int, length: int = 1) -> int or tuple:
        print(f"reg: {register}: len: {length}")

observe this output when running "riden" (power output if OFF):

reg: 0: len: 4
reg: 1: len: 1
reg: 4: len: 16
reg: 4: len: 1
reg: 6: len: 1
reg: 10: len: 1
reg: 11: len: 1
reg: 13: len: 1
reg: 15: len: 1
reg: 16: len: 1
reg: 17: len: 1
reg: 18: len: 1
reg: 19: len: 1
reg: 32: len: 10
reg: 32: len: 1
reg: 38: len: 1
reg: 39: len: 1
reg: 40: len: 1
reg: 41: len: 1

while we should expect only these, for calls "init" and "update":

reg: 4: len: 16
reg: 32: len: 10

As a proof, when I turn power output ON (which is R.V_OUT), then "reg: 10: len: 1" line is not printed.

those single registers reading happened for registers which have 0 (zero) as current value.
so construction:

_v_out = _v_out or self.read(R.V_OUT)

works incorrectly when function input value is set to 0 (zero).
While approach used before refactoring works correctly:

if _v_out is None:
    _v_out = self.read(R.V_OUT)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions