Ivan-Malinin-IBM7968 / go-ethernet-ip

A complete golang implementation of Ethernet/ip

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-ethernet-ip

standard-readme compliant

A complete golang implementation of Ethernet/ip protocol.

This repository contains:

  1. A implementation of ethernet/ip protocol.
  2. A lightweight message router.
  3. Session management.
  4. A lightweight api interface makes you don't need to focus binary steam.
  5. Examples of go-ethernet-ip.

Table of Contents

Background

go-ethernet-ip started with the my own project goplc which used for communication with rockwell control/compactLogix PLCs.

I separate common industrial protocol from ethernet/ip.

If your communication protocol is common industrial protocol, you should move to go-cip which base on this repository.

Install

This project uses golang. Go check them out if you don't have them locally installed.

$ go get github.com/loki-os/go-ethernet-ip

Also go modules is supported.

Usage

I use some cip cases for demonstration.

Before you use these cases.You should block your main thread.Because all logic run in go routine.

func block(){
	some_case()

	// you'd better find other way to do this. Sleep is not recommended.
	time.Sleep(time.Second * 10)
}

Find all LAN devices

Before we start to communication with other device, we need to find them via lan. If you have clear ip skip this step.

devices, err := GetLanDevices(time.Second)

New device

device, err := NewDevice("192.168.0.100")

Device connection config

Device Connect() is optional.You can skip this step to use default config.

Connect() should be call before other function, otherwise it will fail.

cfg := DefaultConfig()
cfg.TCPTimeout = time.Second * 5

device.Connect(cfg)

List identity

identity, err := device.ListIdentity()

List interface

interface, err := device.ListInterface()

List services

services, err := device.ListServices()

Send RRData

device.SendRRData(cpf *commonPacketFormat, timeout typedef.Uint)

Send UnitData

device.SendUnitData(cpf *commonPacketFormat, timeout typedef.Uint)

Disconnect

device.Disconnect()

Maintainers

@末日上投.

Contributing

Feel free to dive in! Open an issue or submit PRs.

License

MIT © 末日上投

About

A complete golang implementation of Ethernet/ip

License:MIT License


Languages

Language:Go 100.0%