Skip to content

Decoding Holding Registers to 16bit binary format  #1033

@Pietro395

Description

@Pietro395

Versions

  • Python: 3.9.13
  • OS: Ubuntu 22.04
  • Pymodbus: 2.5.3
  • Modbus Hardware (if used):

Pymodbus Specific

  • Server: tcp
  • Client: tcp

Description

In reference to the issue #634

I am simulating a real case in which in a modbus server I have to read a holding register in binary format.

Reading the register and using the decode_bits() function I expect to receive a list of 16 bits.
decode_bits() only converts 1 byte.

Code and Logs

# register: 1101000000000000
result = self.connection.read_holding_registers(register, 1, unit=self.slave_unit)
decoder = BinaryPayloadDecoder.fromRegisters(result.registers, Endian.Big, wordorder=Endian.Little)
print(decoder.decode_bits())
# Result: [False, False, False, False, True, False, True, True]
# Expected: [False, False, False, False, False, False, False, False, False, False, False, False, True, False, True, True]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions