Skip to content

[Bug]: Modbus: ModbusOptimizer doesn't check tag specific endianness #2058

@IsmoLeszczynski

Description

@IsmoLeszczynski

What happened?

ModbusOptimizer.processReadResponses(...) always uses the connection default endianness when processing the results, instead of checking for tag specific configurations:

byte[] responseData = response.getResponseDataForTag(modbusTag);
ReadBuffer readBuffer = getReadBuffer(responseData, modbusContext.getByteOrder());
try {
    PlcValue plcValue = DataItem.staticParse(readBuffer, modbusTag.getDataType(),
        modbusTag.getNumberOfElements(),
        modbusContext.getByteOrder() == ModbusByteOrder.BIG_ENDIAN);
    values.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.OK, plcValue));
} catch (ParseException e) {
    values.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.INTERNAL_ERROR, null));
}

I believe the byte-order should be taken from the modbusTag.getByteOrder() if available, and fallback to the default? I have a fix for this that I can PR, but it's built on top of #2055, which is still under review.

Version

v0.13.0-SNAPSHOT

Programming Languages

  • plc4c
  • plc4go
  • plc4j
  • plc4net
  • plc4py

Protocols

  • AB-Ethernet
  • ADS /AMS
  • BACnet/IP
  • C-Bus
  • CANopen
  • EtherNet/IP
  • Firmata
  • IEC-69870
  • KNXnet/IP
  • Modbus
  • OPC-UA
  • Profinet
  • S7
  • S7-light

Metadata

Metadata

Labels

Modbushttps://plc4x.apache.org/users/protocols/modbus.htmljavaPull requests that update Java code

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions