Skip to content

Conversation

@google-labs-jules
Copy link

This change introduces little-endian support for the Modbus library. A byte_order parameter has been added to the client and host classes to allow specifying the byte order for register data, with 'big' as the default. The parameter accepts 'big' or 'little' for a more user-friendly API.

This change introduces little-endian support for the Modbus library.
A `byte_order` parameter has been added to the constructors of the `TCP`
and `Serial` client classes, as well as the `ModbusTCP` and `ModbusRTU`
host classes.

This parameter allows you to specify the byte order for the
register data. The default is big-endian (`>`) for backward
compatibility.

The following modules have been updated:
- `umodbus/common.py`: `CommonModbusFunctions` now handles `byte_order`.
- `umodbus/functions.py`: Data packing/unpacking functions now respect
  the `byte_order`. The PDU header remains big-endian as per the
  Modbus specification.
- `umodbus/tcp.py`: `TCP` and `ModbusTCP` classes now accept `byte_order`.
- `umodbus/serial.py`: `Serial` and `ModbusRTU` classes now accept
  `byte_order`.
- `umodbus/modbus.py`: The `Modbus` host class now handles `byte_order`
  for incoming write requests.
This change introduces little-endian support for the Modbus library.
A `byte_order` parameter has been added to the constructors of the `TCP`
and `Serial` client classes, as well as the `ModbusTCP` and `ModbusRTU`
host classes.

The `byte_order` parameter accepts "big" or "little" as values, with
"big" as the default for backward compatibility. This provides a more
user-friendly API than using ">" or "<".

The following modules have been updated:
- `umodbus/common.py`: `CommonModbusFunctions` now handles `byte_order`.
- `umodbus/functions.py`: Data packing/unpacking functions now respect
  the `byte_order`. The PDU header remains big-endian as per the
  Modbus specification.
- `umodbus/tcp.py`: `TCP` and `ModbusTCP` classes now accept `byte_order`.
- `umodbus/serial.py`: `Serial` and `ModbusRTU` classes now accept
  `byte_order`.
- `umodbus/modbus.py`: The `Modbus` host class now handles `byte_order`
  for incoming write requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant