Skip to content

_build_register should be updated to work with registers with length > 1 #36

Description

@jsiegle

_Emitter._build_register doesn't currently propagate the register's length onto the class it builds:

return _new_class(
class_name,
(RegisterBase,),
{
"address": reg.address,
"payload_type": ProtoPayloadType[reg.type.name],
"payload_class": payload_cls,
},
)

This breaks Device.read() and Device.write() for registers with length > 1, such as the struct-typed settings registers used on the Quac.

Changing the return value to this seems to fix things:

  return _new_class(
      class_name,
      (RegisterBase,),
      {
          "address": reg.address,
          "payload_type": ProtoPayloadType[reg.type.name],
          "payload_class": payload_cls,
          "length": length if length > 1 else None,
      },
  )

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