Skip to content

Commit 04f655e

Browse files
committed
Update readme with remarks about UDP support.
Signed-off-by: toim <[email protected]>
1 parent 2cd4d3c commit 04f655e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ coverage
1818
# Dependency directories (remove the comment below to include it)
1919
# vendor/
2020

21+
main/
22+
2123
### macOS ###
2224
*.DS_Store
2325
.AppleDouble

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Go Report Card](https://goreportcard.com/badge/github.com/aldas/go-modbus-client)](https://goreportcard.com/report/github.com/aldas/go-modbus-client)
66
[![Codecov](https://codecov.io/gh/aldas/go-modbus-client/branch/main/graph/badge.svg)](https://codecov.io/gh/aldas/go-modbus-client)
77

8-
Modbus client (TCP/RTU) over TCP/Serial for Golang.
8+
Modbus client (TCP/RTU) over TCP/UDP/Serial for Golang.
99

1010
* Modbus TCP/IP specification: http://www.modbus.org/specs.php
1111
* Modbus TCP/IP and RTU simpler description: http://www.simplymodbus.ca/TCP.htm
@@ -34,7 +34,7 @@ go get github.com/aldas/go-modbus-client
3434
## Goals
3535

3636
* Packets separate from Client implementation
37-
* Client (TCP/RTU) separated from Modbus packets
37+
* Client (TCP/UDP +RTU) separated from Modbus packets
3838
* Convenience methods to convert register data to/from different data types (with endianess/word order)
3939
* Builders to group multiple fields into request batches
4040

@@ -43,15 +43,17 @@ go get github.com/aldas/go-modbus-client
4343
Higher level API allows you to compose register requests out of arbitrary number of fields and extract those
4444
field values from response registers with convenience methods
4545

46+
Addresses without scheme (i.e. `localhost:5020`) are considered as TCP addresses. For UDP unicast use `udp://localhost:5020`.
47+
4648
```go
47-
b := modbus.NewRequestBuilder("localhost:5020", 1)
49+
b := modbus.NewRequestBuilder("tcp://localhost:5020", 1)
4850

4951
requests, _ := b.Add(b.Uint16(18).UnitID(0).Name("test_do")).
5052
Add(b.Int64(18).Name("alarm_do_1").UnitID(0)).
5153
ReadHoldingRegistersTCP() // split added fields into multiple requests with suitable quantity size
5254

5355
client := modbus.NewTCPClient()
54-
if err := client.Connect(context.Background(), "localhost:5020"); err != nil {
56+
if err := client.Connect(context.Background(), "tcp://localhost:5020"); err != nil {
5557
return err
5658
}
5759
for _, req := range requests {
@@ -76,6 +78,8 @@ for _, req := range requests {
7678

7779
RTU examples to interact with serial port can be found from [serial.md](serial.md)
7880

81+
Addresses without scheme (i.e. `localhost:5020`) are considered as TCP addresses. For UDP unicast use `udp://localhost:5020`.
82+
7983
### Low level packets
8084

8185
```go

0 commit comments

Comments
 (0)