All Projects → things-go → go-modbus

things-go / go-modbus

Licence: MIT license
modbus write in pure go, support rtu,ascii,tcp master library,also support tcp slave.(WIP new implement<old: https://github.com/thinkgos/gomodbus >)

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-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 (+167.74%)
Mutual labels:  modbus, modbus-tcp, modbus-rtu, modbus-master, modbus-slave
ModbusMechanic
Cross platform GUI MODBUS TCP/RTU simulator & gateway. Interprets data types including ascii float and int.
Stars: ✭ 63 (-49.19%)
Mutual labels:  modbus, modbus-tcp, modbus-rtu, modbus-master, modbus-slave
EasyModbusTCP.Java
EasyModbusTCP library for Java implementation
Stars: ✭ 76 (-38.71%)
Mutual labels:  modbus, modbus-tcp, modbus-rtu
huawei solar
Home Assistant integration for Huawei Solar inverters via Modbus
Stars: ✭ 126 (+1.61%)
Mutual labels:  modbus, modbus-tcp, modbus-rtu
solaredge modbus
SolarEdge Modbus data collection library
Stars: ✭ 49 (-60.48%)
Mutual labels:  modbus, modbus-tcp, modbus-rtu
Modbus Tcp Client
PHP client for Modbus TCP and Modbus RTU over TCP (can be used for serial)
Stars: ✭ 89 (-28.23%)
Mutual labels:  modbus, modbus-tcp
Modbridge
Bridge between modbus and MQTT
Stars: ✭ 20 (-83.87%)
Mutual labels:  modbus, modbus-tcp
Modbuspp
A C++ Library for Modbus TCP Protocol
Stars: ✭ 108 (-12.9%)
Mutual labels:  modbus, modbus-tcp
Genmon
Generac Generator Monitoring using a Raspberry Pi and WiFi
Stars: ✭ 143 (+15.32%)
Mutual labels:  modbus, modbus-tcp
Jlibmodbus
JLibModbus is an implementation of the Modbus protocol v1.1b in java language.
Stars: ✭ 149 (+20.16%)
Mutual labels:  modbus, modbus-tcp
QUaModbusClient
Modbus to OPC UA Gateway
Stars: ✭ 38 (-69.35%)
Mutual labels:  modbus, modbus-master
Pymodbus
A full modbus protocol written in python
Stars: ✭ 1,225 (+887.9%)
Mutual labels:  modbus, modbus-tcp
Pyscada
PyScada is a open source scada system that uses the Django framework as backend
Stars: ✭ 233 (+87.9%)
Mutual labels:  modbus, modbus-tcp
Modbustool
A modbus master and slave test tool with import and export functionality, supports TCP, UDP and RTU.
Stars: ✭ 187 (+50.81%)
Mutual labels:  modbus, modbus-tcp
Mbusd
Open-source Modbus TCP to Modbus RTU (RS-232/485) gateway.
Stars: ✭ 233 (+87.9%)
Mutual labels:  modbus, modbus-tcp
Gomodbus
A Modbus client in Go
Stars: ✭ 11 (-91.13%)
Mutual labels:  modbus, modbus-tcp
arduino-modbus-rtu-tcp-gateway
Arduino-based Modbus RTU to Modbus TCP/UDP gateway with web interface. Allows you to connect Modbus RTU slaves (such as sensors, energy meters, HVAC devices) to Modbus TCP/UDP masters (such as home automation systems). You can adjust settings through web interface.
Stars: ✭ 56 (-54.84%)
Mutual labels:  modbus-tcp, modbus-rtu
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 (+558.06%)
Mutual labels:  modbus, modbus-tcp
Modbus
Modbus RTU and TCP support for C#
Stars: ✭ 23 (-81.45%)
Mutual labels:  modbus, modbus-tcp
J2mod
Enhanced Modbus library implemented in the Java programming language
Stars: ✭ 155 (+25%)
Mutual labels:  modbus, modbus-tcp

go modbus

modbus write in pure go, support rtu,ascii,tcp master library,also support tcp slave.

GoDoc Go.Dev reference codecov Action Status Go Report Card Licence Tag Sourcegraph

Supported formats

  • modbus Serial(RTU,ASCII) Client
  • modbus TCP Client
  • modbus TCP Server

Features

  • object pool design,reduce memory allocation
  • fast encode and decode
  • interface design
  • simple API and support raw data api

Installation

Use go get.

    go get github.com/things-go/go-modbus

Then import the package into your own code.

    import modbus "github.com/things-go/go-modbus"

Supported functions


bit access:

  • Read Discrete Inputs
  • Read Coils
  • Write Single Coil
  • Write Multiple Coils

16-bit access:

  • Read Input Registers
  • Read Holding Registers
  • Write Single Register
  • Write Multiple Registers
  • Read/Write Multiple Registers
  • Mask Write Register
  • Read FIFO Queue

Example


modbus RTU/ASCII client see example

package main

import (
	"fmt"
	"time"

	"github.com/goburrow/serial"

	modbus "github.com/things-go/go-modbus"
)

func main() {
	p := modbus.NewRTUClientProvider(modbus.WithEnableLogger(),
		modbus.WithSerialConfig(serial.Config{
			Address:  "/dev/ttyUSB0",
			BaudRate: 115200,
			DataBits: 8,
			StopBits: 1,
			Parity:   "N",
			Timeout:  modbus.SerialDefaultTimeout,
		}))

	client := modbus.NewClient(p)
	err := client.Connect()
	if err != nil {
		fmt.Println("connect failed, ", err)
		return
	}
	defer client.Close()

	fmt.Println("starting")
	for {
		_, err := client.ReadCoils(3, 0, 10)
		if err != nil {
			fmt.Println(err.Error())
		}

		//	fmt.Printf("ReadDiscreteInputs %#v\r\n", results)

		time.Sleep(time.Second * 2)
	}
}

modbus TCP client see example

package main

import (
	"fmt"
	"time"

	modbus "github.com/things-go/go-modbus"
)

func main() {
	p := modbus.NewTCPClientProvider("192.168.199.188:502", modbus.WithEnableLogger())
	client := modbus.NewClient(p)
	err := client.Connect()
	if err != nil {
		fmt.Println("connect failed, ", err)
		return
	}
	defer client.Close()

	fmt.Println("starting")
	for {
		_, err := client.ReadCoils(1, 0, 10)
		if err != nil {
			fmt.Println(err.Error())
		}

		//	fmt.Printf("ReadDiscreteInputs %#v\r\n", results)

		time.Sleep(time.Second * 2)
	}
}

modbus TCP server see example

package main

import (
	modbus "github.com/things-go/go-modbus"
)

func main() {
	srv := modbus.NewTCPServer()
	srv.LogMode(true)
	srv.AddNodes(
		modbus.NewNodeRegister(
			1,
			0, 10, 0, 10,
			0, 10, 0, 10),
		modbus.NewNodeRegister(
			2,
			0, 10, 0, 10,
			0, 10, 0, 10),
		modbus.NewNodeRegister(
			3,
			0, 10, 0, 10,
			0, 10, 0, 10))

	err := srv.ListenAndServe(":502")
	if err != nil {
		panic(err)
	}
}

References


JetBrains OS licenses

go-modbus had been being developed with GoLand under the free JetBrains Open Source license(s) granted by JetBrains s.r.o., hence I would like to express my thanks here.

Donation

if package help you a lot,you can support us by:

Alipay

alipay

WeChat Pay

wxpay

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].