https://github.com/future-architect/go-mcprotocol
MC Protocol(MELSEC Communication Protocol) client implementation for golang
https://github.com/future-architect/go-mcprotocol
Last synced: 5 months ago
JSON representation
MC Protocol(MELSEC Communication Protocol) client implementation for golang
- Host: GitHub
- URL: https://github.com/future-architect/go-mcprotocol
- Owner: future-architect
- License: apache-2.0
- Created: 2019-10-11T04:47:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-18T06:51:32.000Z (over 4 years ago)
- Last Synced: 2025-05-07T21:08:57.810Z (8 months ago)
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 45
- Watchers: 15
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-mcprotocol
go-mcprotocol is a library for PLC (Programmable Logic Controller) access
## Project Status
**Work In Progress**
## Usage for Library
You can read plc register bellow codes.
```go
client, _ := mcp.New3EClient(opts.Host, opts.Port, mcp.NewLocalStation())
read, _ := client.Read("D", 100, 3)
registerBinary, _ := mcp.NewParser().Do(read)
fmt.Println(string(registerBinary.Payload))
```
#### Health Check
```go
if err := client.HealthCheck(); err != nil {
log.Fatalf("failed health check for plc: %v", err)
}
```
## Usage Tool
## Output file format
Format is CSV. Items are timestamp and Base64 encoded MC Protocol response.
```csv
2019-10-07T07:08:00.3623052Z,0AAA//8DAAwAAAAAAAAAAAAAAAAA
2019-10-07T07:08:00.8622182Z,0AAA//8DAAwAAAAAAAAAAAAAAAAA
2019-10-07T07:08:01.3616205Z,0AAA//8DAAwAAAAAAAAAAAAAAAAA
...
```
## Usage for tool
Collect the register valuesof PLC by MC Protocol(MELSEC Communication Protocol).
This tools is gather plc register data and dump local files.
### Examples
```bash
$ plcmirror -H -P --device D --offset 100 --num 10 --dir /var/log/plcmirror
```
### Options
```bash
> plcmirror -help
Usage:
plcmirror [OPTIONS]
Application Options:
/H, /host: PLC hostname
/P, /port: Melsec communication protocol port number
/D, /device: Register name like D that is mirror target
/O, /offset: PLC register offset addr that is mirror target
/N, /num: number of device points
/dir: file output path (default: .)
/I, /interval: mirroring interval [milli sec] (default: 500)
Help Options:
/? Show this help message
/h, /help Show this help message
```
# License
Apache 2