OpenModSim icon indicating copy to clipboard operation
OpenModSim copied to clipboard

LE/BE and Swapped

Open stg opened this issue 9 months ago • 0 comments

Just two cents from someone working with and writing various slave and master implementations for Modbus for around 20 years now.

  1. Modbus is Big Endian, also referred to as "network byte order" - the most common endianness for communication. When Open ModSim is set to "LE" (which is also the default) it decodes big-endian values correctly - this seems straight up wrong to me.
    Example: For a single register: [ 0x01, 0x02 ] in that order in a serial or TCP stream means 0x0102 or 258 decimal. This is indisputably big-endian interpretation, as per the definition of endianness as well as the modbus specification.

  2. The most common way, by far, to send multi-register values is most significant word/register first. When Open ModSim is set to "Swapped" (my preference is the less ambiguous term "Reversed") it decodes these correctly - a bit confusing
    Example: For a 32-bit register: [ 0x01, 0x02, 0x03, 0x04 ] in that order in the stream most commonly means 0x01020304 or 16909060 decimal. This is most significant word/register first and the most common (easily 90% or more) order, thus a little irksome to call "Swapped".

Oh and, yeah, someone (you) finally did this! Great f---ing work! Seriously, this was direly needed (because ugh... modbustools.com ammirite?)

stg avatar Mar 18 '25 19:03 stg