Skip to content

ReadDeviceInformationRequest fails with struct error #307

@dhoomakethu

Description

@dhoomakethu

Versions

Pymodbus Specific

  • Client: rtu-sync

Description

Trying to execute mei message (ReadDeviceInformationRequest) and ReportSlaveIdRequest results in struct error. This is partly because these requests do not get_response_pdu_size methods implemented and expected response length is passed as None . The _wait_for_data method in client.sync.ModbusSerialClient class for some devices does not wait for the complete data to come in to the read buffer, thereby returning partial data .

Code and Logs

error: unpack requires a string argument of length 2
(7 additional frame(s) were not displayed)
...
  File "pymodbus/transaction.py", line 164, in execute
    request.unit_id)
  File "pymodbus/framer/rtu_framer.py", line 217, in processIncomingPacket
    if self.checkFrame():
  File "pymodbus/framer/rtu_framer.py", line 89, in checkFrame
    self.populateHeader()
  File "pymodbus/framer/rtu_framer.py", line 152, in populateHeader
    size = pdu_class.calculateRtuFrameSize(data)
  File "pymodbus/mei_message.py", line 118, in calculateRtuFrameSize
    _, object_length = struct.unpack('>BB', buffer[size:size+2])

unpack requires a string argument of length 2

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