# stephane/libmodbus

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/stephane-libmodbus).**

4,180 stars · 1,930 forks · C · LGPL-2.1

## Links

- GitHub: https://github.com/stephane/libmodbus
- Homepage: http://libmodbus.org
- awesome-repositories: https://awesome-repositories.com/repository/stephane-libmodbus.md

## Topics

`automation` `c` `libmodbus` `modbus`

## Description

libmodbus is a portable C library that implements the Modbus protocol stack for industrial hardware communication. It provides a set of tools for reading and writing coils and registers on industrial controllers and sensors, functioning as both a client and a protocol server.

The library supports multiple transport layers, including a Modbus TCP stack for IPv4 and IPv6 network communication and a Modbus RTU driver for serial communication. It distinguishes itself through specialized data conversion utilities that handle byte-swapping and endianness for floating-point numbers and bit-field mapping to ensure compatibility across different hardware memory layouts.

The project covers a broad range of industrial communication capabilities, including atomic register operations, device identification, and the management of protocol constraints or device quirks. It provides comprehensive connectivity management for serial ports—including Request to Send signaling—and network sockets, alongside memory-mapped server buffers for simulating device memory.

This cross-platform implementation is compatible with Linux, Windows, macOS, and FreeBSD.

## Tags

### Networking & Communication

- [Industrial Protocol Stacks](https://awesome-repositories.com/f/networking-communication/industrial-protocol-stacks.md) — Provides a complete C implementation of the Modbus industrial communication protocol stack.
- [Modbus Server Implementations](https://awesome-repositories.com/f/networking-communication/modbus-server-implementations.md) — Provides a full software implementation of the Modbus server role, managing memory-mapped registers for industrial device simulation. ([source](http://libmodbus.org/reference/))
- [Client Connectivity Management](https://awesome-repositories.com/f/networking-communication/client-connectivity-management.md) — Manages the assignment of sockets and file descriptors within a communication context to handle multiple client requests. ([source](http://libmodbus.org/reference/modbus_set_socket/))
- [Cyclic Redundancy Checks](https://awesome-repositories.com/f/networking-communication/cyclic-redundancy-checks.md) — Calculates and verifies CRC checksums to ensure data integrity for binary serial frames.
- [Industrial Coil Writing](https://awesome-repositories.com/f/networking-communication/industrial-coil-writing.md) — Sets the status of multiple remote binary output coils using an array of boolean values. ([source](http://libmodbus.org/reference/modbus_write_bits/))
- [Industrial Input Bit Retrieval](https://awesome-repositories.com/f/networking-communication/industrial-input-bit-retrieval.md) — Retrieves the status of discrete input bits from remote industrial devices as boolean values. ([source](http://libmodbus.org/reference/modbus_read_input_bits/))
- [Industrial Server Implementations](https://awesome-repositories.com/f/networking-communication/industrial-server-implementations.md) — Implements industrial server endpoints that host memory-mapped registers and provide standardized access to device data.
- [Modbus Data Retrieval](https://awesome-repositories.com/f/networking-communication/modbus-data-retrieval.md) — Retrieves the boolean state of multiple remote binary coils from industrial devices. ([source](http://libmodbus.org/reference/modbus_read_bits/))
- [Bidirectional Data Exchange](https://awesome-repositories.com/f/networking-communication/modbus-data-retrieval/bidirectional-data-exchange.md) — Enables bidirectional data exchange with industrial devices over serial or Ethernet to synchronize hardware states. ([source](https://cdn.jsdelivr.net/gh/stephane/libmodbus@master/README.md))
- [Industrial Register Writing](https://awesome-repositories.com/f/networking-communication/modbus-data-retrieval/industrial-register-writing.md) — Sends a sequence of data values to specific holding register addresses on a remote device. ([source](http://libmodbus.org/reference/modbus_write_registers/))
- [Modbus Protocol Libraries](https://awesome-repositories.com/f/networking-communication/modbus-protocol-libraries.md) — Provides a portable C implementation for reading and writing coils and registers on industrial controllers.
- [Modbus RTU Networking](https://awesome-repositories.com/f/networking-communication/modbus-rtu-networking.md) — Implements binary serial communication using the Modbus RTU protocol, including CRC and baud rate management.
- [Modbus TCP Implementations](https://awesome-repositories.com/f/networking-communication/modbus-tcp-implementations.md) — Provides network stacks enabling client and server data exchange using the Modbus protocol over TCP/IP. ([source](http://libmodbus.org))
- [Modbus TCP Networking](https://awesome-repositories.com/f/networking-communication/modbus-tcp-networking.md) — Implements the Modbus protocol over TCP/IP networking, supporting IPv4 and IPv6 sockets.
- [Remote Device Connectivity](https://awesome-repositories.com/f/networking-communication/remote-device-connectivity.md) — Establishes bidirectional communication links with remote hardware over both TCP/IP and serial interfaces. ([source](http://libmodbus.org/getting_started/))
- [Device Identifier Assignment](https://awesome-repositories.com/f/networking-communication/remote-device-connectivity/device-identifier-assignment.md) — Assigns the specific target Slave ID to a communication context to identify the remote industrial device. ([source](http://libmodbus.org/reference/modbus_set_slave/))
- [Target Device Address Retrieval](https://awesome-repositories.com/f/networking-communication/tcp-connection-lifecycles/tcp-client-connections/connection-addressing/target-device-address-retrieval.md) — Reads the target device identifier from the communication context to determine which slave is being addressed. ([source](http://libmodbus.org/reference/modbus_get_slave/))
- [Automatic Connection Recovery](https://awesome-repositories.com/f/networking-communication/connection-pooling/grpc-connection-pools/grpc-connection-management/automatic-connection-recovery.md) — Automatically attempts to re-establish lost network links and flush buffers to maintain industrial communication stability. ([source](http://libmodbus.org/reference/modbus_set_error_recovery/))
- [Industrial Device Responses](https://awesome-repositories.com/f/networking-communication/industrial-device-responses.md) — Implements logic for analyzing incoming industrial protocol requests and transmitting corresponding responses based on memory mapping. ([source](http://libmodbus.org/reference/modbus_reply/))
- [Protocol Validation Bypasses](https://awesome-repositories.com/f/networking-communication/protocol-validation-bypasses.md) — Overrides standard protocol rules to support non-compliant devices by enabling extended addresses. ([source](http://libmodbus.org/reference/modbus_enable_quirks/))
- [Connection Context Management](https://awesome-repositories.com/f/networking-communication/socket-communication/connection-context-management.md) — Uses state structures to encapsulate connection handles and configurations across API calls.

### Hardware & IoT

- [Serial Port Interfaces](https://awesome-repositories.com/f/hardware-iot/connectivity-iot/hardware-communication/serial-port-interfaces.md) — Initializes communication by configuring serial port parameters including baud rate, parity, and data bits. ([source](http://libmodbus.org/reference/modbus_new_rtu/))
- [Industrial Data Acquisition](https://awesome-repositories.com/f/hardware-iot/industrial-data-acquisition.md) — Implements processes for reading and writing binary registers and bits from industrial hardware to monitor and control processes.
- [Serial Parameter Configurations](https://awesome-repositories.com/f/hardware-iot/serial-parameter-configurations.md) — Configures baud rates, parity, and stop bits to match the electrical standards of connected hardware. ([source](http://libmodbus.org/reference/modbus_rtu_set_serial_mode/))

### Operating Systems & Systems Programming

- [Modbus RTU Drivers](https://awesome-repositories.com/f/operating-systems-systems-programming/modbus-rtu-drivers.md) — Ships a low-level serial driver handling binary framing and CRC checks for Modbus RTU communication.
- [Network Socket I/O](https://awesome-repositories.com/f/operating-systems-systems-programming/network-socket-i-o.md) — Uses standard BSD sockets for bidirectional data transmission over Ethernet.
- [C Network Protocol Implementations](https://awesome-repositories.com/f/operating-systems-systems-programming/c-network-protocol-implementations.md) — Implements a low-level network protocol stack written in C for maximum efficiency and portability.
- [Connection Timeout Management](https://awesome-repositories.com/f/operating-systems-systems-programming/connection-timeout-management.md) — Manages byte and response timeout intervals to prevent application hangs during data transmission. ([source](http://libmodbus.org/reference/))
- [Cross-Platform C Libraries](https://awesome-repositories.com/f/operating-systems-systems-programming/cross-platform-c-libraries.md) — Provides a portable C library for low-level system integration across multiple operating systems.
- [Floating-Point Register Serialization](https://awesome-repositories.com/f/operating-systems-systems-programming/floating-point-register-loading/floating-point-register-serialization.md) — Serializes floating-point values into byte sequences tailored for industrial register layouts. ([source](http://libmodbus.org/reference/modbus_set_float_cdab/))
- [Modbus Memory Mapping](https://awesome-repositories.com/f/operating-systems-systems-programming/modbus-memory-mapping.md) — Implements the allocation and initialization of contiguous memory arrays to simulate Modbus coils and registers. ([source](http://libmodbus.org/reference/modbus_mapping_new/))

### Scientific & Mathematical Computing

- [Industrial Coil Setters](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/algorithms-and-complexity/algorithms/bit-manipulation-techniques/bit-range-manipulators/single-bit-setters/industrial-coil-setters.md) — Sets a specific coil address on a remote device to a true or false state. ([source](http://libmodbus.org/reference/modbus_write_bit/))
- [Endian-Aware Float Formatting](https://awesome-repositories.com/f/scientific-mathematical-computing/floating-point-precision-conversions/endian-aware-float-formatting.md) — Formats floating-point numbers into byte sequences with swapped orders for industrial hardware compatibility.
- [Register-Based Float Formatting](https://awesome-repositories.com/f/scientific-mathematical-computing/floating-point-string-conversion/integer-to-float-converters/general-float-converters/register-based-float-formatting.md) — Formats floats into byte sequences distributed across multiple hardware registers. ([source](http://libmodbus.org/reference/modbus_set_float_badc/))
- [Byte-Swapped Float Parsing](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/arithmetic-number-types/floating-point-handlers/floating-point-packers/byte-swapped-float-parsing.md) — Provides utilities for converting byte sequences into floating-point numbers while accounting for non-standard hardware byte orders.
- [Float-to-Byte Packing](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/arithmetic-number-types/floating-point-handlers/floating-point-packers/float-to-byte-packing.md) — Converts floating-point values into raw 4-byte formats for transmission to industrial devices. ([source](http://libmodbus.org/reference/modbus_set_float/))
- [Register-to-Float Unpacking](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/arithmetic-number-types/floating-point-handlers/floating-point-packers/register-to-float-unpacking.md) — Reconstructs floating-point numbers from multiple 16-bit Modbus registers using specific byte orders. ([source](http://libmodbus.org/reference/modbus_get_float_cdab/))

### Software Engineering & Architecture

- [Industrial Register Writing](https://awesome-repositories.com/f/software-engineering-architecture/state-management/hardware-register-state-managers/register-configuration-managers/industrial-register-writing.md) — Sends a 16-bit value to a specific holding register address on a remote device. ([source](http://libmodbus.org/reference/modbus_write_register/))
- [Device Memory Simulation](https://awesome-repositories.com/f/software-engineering-architecture/block-based-data-models/data-block-memory-management/contiguous-memory-buffers/device-memory-simulation.md) — Emulates industrial device memory using contiguous memory blocks for coils and registers.
- [Protocol Error Code Mapping](https://awesome-repositories.com/f/software-engineering-architecture/exception-to-error-code-translation/protocol-error-code-mapping.md) — Maps internal failures to Modbus protocol-defined exception codes for transmission back to the client. ([source](http://libmodbus.org/reference/modbus_reply_exception/))
- [Protocol](https://awesome-repositories.com/f/software-engineering-architecture/resource-management/kernel/quirks/protocol.md) — Toggles protocol-level behavioral deviations to support non-compliant industrial hardware. ([source](http://libmodbus.org/reference/modbus_disable_quirks/))
- [Transport-Agnostic Interfaces](https://awesome-repositories.com/f/software-engineering-architecture/transport-agnostic-interfaces.md) — Provides a uniform API that abstracts the underlying transport medium, whether TCP, IPv6, or serial.

### Data & Databases

- [Device Response Timeouts](https://awesome-repositories.com/f/data-databases/connection-pools/timeout-management/request-timeouts/device-response-timeouts.md) — Configures the interval to wait for a response from a remote industrial device before reporting a timeout error. ([source](http://libmodbus.org/reference/modbus_set_response_timeout/))

### Development Tools & Productivity

- [Cross-Platform Hardware Communication](https://awesome-repositories.com/f/development-tools-productivity/cross-platform-hardware-controllers/cross-platform-hardware-communication.md) — Enables portable C applications to communicate with industrial equipment across Linux, Windows, macOS, and FreeBSD.

### DevOps & Infrastructure

- [Connection Termination](https://awesome-repositories.com/f/devops-infrastructure/client-connectivity-tools/connection-termination.md) — Gracefully terminates active communication sessions to release network and serial hardware resources. ([source](http://libmodbus.org/reference/modbus_close/))

### Programming Languages & Runtimes

- [Data Type Conversions](https://awesome-repositories.com/f/programming-languages-runtimes/data-type-conversions.md) — Provides utilities for transforming raw bytes into integers and floating-point numbers to match device memory layouts. ([source](http://libmodbus.org/reference/))

### System Administration & Monitoring

- [Server](https://awesome-repositories.com/f/system-administration-monitoring/request-timeouts/server.md) — Defines the specific duration a Modbus server waits for a client request before triggering a timeout. ([source](http://libmodbus.org/reference/modbus_set_indication_timeout/))

### Part of an Awesome List

- [Communication Protocols](https://awesome-repositories.com/f/awesome-lists/devtools/communication-protocols.md) — C library for Modbus communication across multiple operating systems.
