Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Home
  • Knowledge base
  • Contact Us
  • Home
  • Connectors
  • Modbus

Word (endianness) & Byte-Swapping

Word-Swappiong (endianness) & Byte-swapping in Modbus

Written by Benjamin Pinnerup

Updated at December 6th, 2024

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Installation & Technical information
    Introduction SIA Connect Standalone SIA Connect ANY-Ware Cellular & WiFi connectivity
  • Configuration in the Web UI
    Getting started with the UI Connectors Instances Items Mapping Data System Network Tools & Add-ons DigiCert IoT Trust Manager
  • Connectors
    Siemens S7 Azure IoT Ethernet/IP Mitsubishi MELSEC OPC-UA Server SQL MQTT Omron Host Link REST API Omron FINS Keyence Beckhoff TwinCAT BACnet Virtual OPC-UA Client MS SQL File M-Bus Modbus
  • Scripting & Variables
    Data formatting
  • Developers
    API documentation Shadow API
  • Tutorials & Guides
    InfluxDB AWS IoT Core - Amazon Web Services Microsoft Power BI KaaIoT Siemens S7 AVEVA Insight SIA Connect Demo Rack Grafana Azure
  • General
+ More

Table of Contents

Introduction Quick overview Word swapping Byte swapping Byte and Word swapping Word-Swapping (Endianness) Byte-Swapping Word & Byte swapping

Articles in this section:

  • Modbus TCP - Instance & item setup
  • Word (endianness) & Byte-Swapping
  • Modbus RTU - Instance & Item setup

 

Introduction

Across various brand and utilization of the Modbus protocol, endianness and byte-swapping has been introduced. To better support the variations across Modbus, SIA Connect allows you to configure the reading of Modbus registers. A register has the size of a single word, 2 bytes. 

 

Quick overview

Below tables gives you a brief overview of the swapping of words and bytes. Values encapsulated into [ ] symbolizes a register.

Word swapping

Big endian Little endian (word swap) Example
[ a b ] [ c d ] [ c d ] [ a b ] [ 0x12 0x34 ] [ 0x56 0x78 ] → [ 0x56 0x78 ] [ 0x12 0x34 ]

 

Byte swapping

Non-swapped Byte Swapped Example
[ a b ] [ b c ] [ 0x12 0x34 ] → [ 0x34 0x12 ]

 

Byte and Word swapping

Non-swapped Byte and Word swapped Example
[ a b ] [ c d ] [ d c ] [ b a ] [ 0x12 0x34 ] [ 0x56 0x78 ] → [ 0x78 0x56 ] [ 0x34 0x12 ]

 

 

Word-Swapping (Endianness)

Endianness is applied when reading values that span across more than one register - eg. INT32, FLOAT, DWORD, etc. 

You can choose between big endian and little endian. 

Big endian Little endian

Example when reading 0x12345678 from 2 registers

Register 0 Register 1
0x1234 0x5678

 

Example when reading 0x1234 from 2 registers

Register 0 Register 1
0x5678 0x1234

 

Byte-Swapping

Byte-swapping is applied for each individual register being read. You can choose between First Byte High and First Byte Low

First byte high First byte low

Example when reading 0x1234 from 1 register

Byte 0 Byte 1
0x12 0x34

 

Example when reading 0x1234 from 1 register

Byte 0 Byte 1
0x34 0x12

 

 

Word & Byte swapping

Combining both word & byte swapping yield the below data formatting:

No swapping First byte low

Example when reading 0x12345678 from 2 registers

Register 0 Register 1
0x1234 0x5678

 

Example when reading 0x12345678 from 2 registers

Register 0 Register 1
0x7856 0x3412

 

 

word sequence byte order byte swapping endianness word swapping

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Modbus TCP - Instance & item setup
  • Modbus RTU - Instance & Item setup

0
0
Expand