All Projects → fanzhe98 → Modbuspp

fanzhe98 / Modbuspp

Licence: gpl-3.0
A C++ Library for Modbus TCP Protocol

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Modbuspp

Modbus Tcp Client
PHP client for Modbus TCP and Modbus RTU over TCP (can be used for serial)
Stars: ✭ 89 (-17.59%)
Mutual labels:  modbus, modbus-tcp
Iotclient
这是一个物联网设备通讯协议实现客户端,将会包括主流PLC通信读取、ModBus协议、Bacnet协议等常用工业通讯协议。本组件终身开源免费,采用最宽松的MIT开源协议,您可以随意修改和商业使用(商业使用请做好评估和测试)。
Stars: ✭ 311 (+187.96%)
Mutual labels:  tcp, modbus
rodbus
Rust implementation of Modbus with idiomatic bindings for C, C++, .NET, and Java
Stars: ✭ 34 (-68.52%)
Mutual labels:  modbus, modbus-tcp
node-drivers
Industrial protocol drivers in node.js
Stars: ✭ 20 (-81.48%)
Mutual labels:  tcp, modbus
Gomodbus
A Modbus client in Go
Stars: ✭ 11 (-89.81%)
Mutual labels:  modbus, modbus-tcp
ModbusMechanic
Cross platform GUI MODBUS TCP/RTU simulator & gateway. Interprets data types including ascii float and int.
Stars: ✭ 63 (-41.67%)
Mutual labels:  modbus, modbus-tcp
Node Modbus
Modbus TCP Client/Server implementation for Node.JS
Stars: ✭ 313 (+189.81%)
Mutual labels:  modbus, modbus-tcp
EasyModbusTCP.Java
EasyModbusTCP library for Java implementation
Stars: ✭ 76 (-29.63%)
Mutual labels:  modbus, modbus-tcp
Modbus
Modbus RTU and TCP support for C#
Stars: ✭ 23 (-78.7%)
Mutual labels:  modbus, modbus-tcp
Hslcommunication
An industrial IoT underlying architecture framework, focusing on the underlying technical communications and cross-platform, cross-language communication functions, to achieve a variety of mainstream PLC data reading and writing, to achieve modbus of various protocols read and write, and so on, to support the rapid construction of industrial upper computer software, configuration software, SCADA software, factory mes system, To help enterprise Industry 4.0 take-off, to achieve intelligent manufacturing, smart factory goals. The main PLC contains Siemens, Mitsubishi, Omron, Panasonic, Modbus, AB-PLC, Redis
Stars: ✭ 816 (+655.56%)
Mutual labels:  modbus, modbus-tcp
huawei solar
Home Assistant integration for Huawei Solar inverters via Modbus
Stars: ✭ 126 (+16.67%)
Mutual labels:  modbus, modbus-tcp
Emodbus
Modbus library for both RTU and TCP protocols. Primarily developed on and for ESP32 MCUs.
Stars: ✭ 29 (-73.15%)
Mutual labels:  tcp, modbus
modbus-esp8266
Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.
Stars: ✭ 332 (+207.41%)
Mutual labels:  modbus, modbus-tcp
go-modbus
modbus write in pure go, support rtu,ascii,tcp master library,also support tcp slave.(WIP new implement<old: https://github.com/thinkgos/gomodbus >)
Stars: ✭ 124 (+14.81%)
Mutual labels:  modbus, modbus-tcp
Modbus-STM32-HAL-FreeRTOS
Modbus TCP and RTU, Master and Slave for STM32 using Cube HAL and FreeRTOS
Stars: ✭ 272 (+151.85%)
Mutual labels:  tcp, modbus
solaredge modbus
SolarEdge Modbus data collection library
Stars: ✭ 49 (-54.63%)
Mutual labels:  modbus, modbus-tcp
Ohsce
PHP HI-REL SOCKET TCP/UDP/ICMP/Serial .高可靠性PHP通信&控制框架SOCKET-TCP/UDP/ICMP/硬件Serial-RS232/RS422/RS485 AND MORE!
Stars: ✭ 206 (+90.74%)
Mutual labels:  tcp, modbus
Modbus.net
A high extensible hardware communication platform using C#
Stars: ✭ 244 (+125.93%)
Mutual labels:  tcp, modbus
Easymodbustcp.net
Modbus TCP, Modbus UDP and Modbus RTU client/server library for .NET implementations
Stars: ✭ 358 (+231.48%)
Mutual labels:  modbus, modbus-tcp
Modbridge
Bridge between modbus and MQTT
Stars: ✭ 20 (-81.48%)
Mutual labels:  modbus, modbus-tcp

MODBUS++ (MODBSPP) V0.2

0 Info, Updates and Discalimer

0.0 Info

MODBUS++ (MODBUSPP) is an header-only open source c++ class/ library making an encapsulation of Modbus TCP Protocol.

MODBUS++ is providing a more OOP friendly syntax.

The code has dependencies on libary on Linux for TCP/IP, if you want to use this in Windows, please check out winsock2 and rewrite portion of code of socket to be compatible with Windows operating system.

0.1 Updates

UPDATES in V0.2 compared to V0.1):

  1. Cleand up some shitty code
  2. Removed exceptions, using error message instead
  3. Removed Enums, placing #define instead
  4. Fixed some bugs (referencing to @konsolenritter's fix)
  5. Combine files into a header only library

0.2 Disclaimer

The code was taken from one of my hack project and wrapped into a header and I take no warranty or responsibility of the code, as mentioned in license. Issues and emails are welcomed, and I will do by best to reply. However I generally do NOT have time to fix it oftenly, due to school and work. The code was written within 5 hours and I knew shit/bugs/issues are in the code, by indicating it with a version number. There are NO points HARRASING me through email for anything unusable.

1 Usage

To use the library, please follow the steps below. Please note current library is only compatible with Linux distributions because of the socket library dependencies.

1.1 Download

Download the MODBUS++, you can:

1.2 Include In your code

Copy the "moodbus.h" to your include directory and include the code whenever appropriate:

include "modbus.h"

2 Getting Started with a Example

2.1 Getting the Example

Checkout example.cpp for a example usage of MODBUSPP. Please note that the code should be compiled using c++11 compilers. A sample CMakeLists.txt is included. To build example:

2.1.1 CMAKE

mkdir build
cd build
cmake ..
make

2.1.2 G++

g++ example.cpp --std=c++11 -o example

2.2 Tutorials

Let's break the code down, before you read this, reference to example.cpp. The example shows basic usages of how to create a modbus client connecting to a modbus server and perform modbus operations in your program.

Include the header

To start with, be sure to include the modbus.h header in your program

#include "modbus.h"

This line includes the header modbus.h from the library, this will tell the compiler to look for functions and variables in the related file.

Create and connects a mobus server

Before performing any modbus operations, a connection needed to be setup between the modbus client(your program) and a modbus server(could be a controller).

modbus mb = modbus("127.0.0.1", 502); mb.modbus_set_slave_id(1); mb.modbus_connect();

These lines creates local modbus client with target IP address at 127.0.0.1 and port at 502, a server with id 1.

Performe Mobus Operations

Modbus usually have 2 types of operations, reading and writing. Reading operations include reading a coil, reading input bits, reading holding registers, and reading input registers. Writing Operations include writing sigle coil, wirting single register, writing multiple coil, and writing multiple registers. Be sure to create a connection before performing any operations. Modbus is relatively low-level protocols. It is useful to have strong computer structure knowledge to understand it.

  1. The following line show how to read a coil (function 0x01). These lines read a bit from the coil at address 0.

bool read_coil; mb.modbus_read_coils(0, 1, &read_coil);

  1. The following lines show how to read input bits(discrete input) (function 0x02). These lines read a bit from discrete inputs at address 0.

bool read_bits; mb.modbus_read_input_bits(0, 1, &read_bits);

  1. The follwing lines show how to read holding registers (function 0x03). These lines read a word(16 bits) from holding registers starting at address 0.

uint16_t read_holding_regs[1]; mb.modbus_read_holding_registers(0, 1, read_holding_regs);

  1. The following lines show how to Read input registers (function 0x04). These lines read a word(16 bits) from input registers starting at address 0.

uint16_t read_input_regs[1]; mb.modbus_read_input_registers(0, 1, read_input_regs);

  1. The following lines show how to write single coil (function 0x05). These lines write a bit to the coil at address 0.

mb.modbus_write_coil(0, true);

  1. The following lines show how to write single register (function 0x06). These lines write a word(16 bits) to the register at address 0.

mb.modbus_write_register(0, 123);

  1. The following lines show how to write multiple coils (function 0x0F). These lines write multiple bits to the coil starting from address 0, for a length of 4.

bool write_cols[4] = {true, true, true, true}; mb.modbus_write_coils(0,4,write_cols);

  1. The following lines show how to write multiple regs (function 0x10). These lines write multiple words to the register starting from address 0, for a length of 4.

uint16_t write_regs[4] = {123, 123, 123}; mb.modbus_write_registers(0, 4, write_regs);

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].