| 1 | Description: remove tests that needs a modbus simulator which is not yet available |
| 2 | Author: Thorsten Alteholz <[email protected]> |
| 3 | Index: golang-github-goburrow-modbus/test/asciiclient_test.go |
| 4 | =================================================================== |
| 5 | --- golang-github-goburrow-modbus.orig/test/asciiclient_test.go 2020-12-08 19:39:28.373223723 +0000 |
| 6 | +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 |
| 7 | @@ -1,49 +0,0 @@ |
| 8 | -// Copyright 2014 Quoc-Viet Nguyen. All rights reserved. |
| 9 | -// This software may be modified and distributed under the terms |
| 10 | -// of the BSD license. See the LICENSE file for details. |
| 11 | - |
| 12 | -package test |
| 13 | - |
| 14 | -import ( |
| 15 | - "log" |
| 16 | - "os" |
| 17 | - "testing" |
| 18 | - |
| 19 | - "github.com/goburrow/modbus" |
| 20 | -) |
| 21 | - |
| 22 | -const ( |
| 23 | - asciiDevice = "/dev/pts/6" |
| 24 | -) |
| 25 | - |
| 26 | -func TestASCIIClient(t *testing.T) { |
| 27 | - // Diagslave does not support broadcast id. |
| 28 | - handler := modbus.NewASCIIClientHandler(asciiDevice) |
| 29 | - handler.SlaveId = 17 |
| 30 | - ClientTestAll(t, modbus.NewClient(handler)) |
| 31 | -} |
| 32 | - |
| 33 | -func TestASCIIClientAdvancedUsage(t *testing.T) { |
| 34 | - handler := modbus.NewASCIIClientHandler(asciiDevice) |
| 35 | - handler.BaudRate = 19200 |
| 36 | - handler.DataBits = 8 |
| 37 | - handler.Parity = "E" |
| 38 | - handler.StopBits = 1 |
| 39 | - handler.SlaveId = 12 |
| 40 | - handler.Logger = log.New(os.Stdout, "ascii: ", log.LstdFlags) |
| 41 | - err := handler.Connect() |
| 42 | - if err != nil { |
| 43 | - t.Fatal(err) |
| 44 | - } |
| 45 | - defer handler.Close() |
| 46 | - |
| 47 | - client := modbus.NewClient(handler) |
| 48 | - results, err := client.ReadDiscreteInputs(15, 2) |
| 49 | - if err != nil || results == nil { |
| 50 | - t.Fatal(err, results) |
| 51 | - } |
| 52 | - results, err = client.ReadWriteMultipleRegisters(0, 2, 2, 2, []byte{1, 2, 3, 4}) |
| 53 | - if err != nil || results == nil { |
| 54 | - t.Fatal(err, results) |
| 55 | - } |
| 56 | -} |
| 57 | Index: golang-github-goburrow-modbus/test/rtuclient_test.go |
| 58 | =================================================================== |
| 59 | --- golang-github-goburrow-modbus.orig/test/rtuclient_test.go 2020-12-08 19:39:28.377224009 +0000 |
| 60 | +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 |
| 61 | @@ -1,49 +0,0 @@ |
| 62 | -// Copyright 2014 Quoc-Viet Nguyen. All rights reserved. |
| 63 | -// This software may be modified and distributed under the terms |
| 64 | -// of the BSD license. See the LICENSE file for details. |
| 65 | - |
| 66 | -package test |
| 67 | - |
| 68 | -import ( |
| 69 | - "log" |
| 70 | - "os" |
| 71 | - "testing" |
| 72 | - |
| 73 | - "github.com/goburrow/modbus" |
| 74 | -) |
| 75 | - |
| 76 | -const ( |
| 77 | - rtuDevice = "/dev/pts/6" |
| 78 | -) |
| 79 | - |
| 80 | -func TestRTUClient(t *testing.T) { |
| 81 | - // Diagslave does not support broadcast id. |
| 82 | - handler := modbus.NewRTUClientHandler(rtuDevice) |
| 83 | - handler.SlaveId = 17 |
| 84 | - ClientTestAll(t, modbus.NewClient(handler)) |
| 85 | -} |
| 86 | - |
| 87 | -func TestRTUClientAdvancedUsage(t *testing.T) { |
| 88 | - handler := modbus.NewRTUClientHandler(rtuDevice) |
| 89 | - handler.BaudRate = 19200 |
| 90 | - handler.DataBits = 8 |
| 91 | - handler.Parity = "E" |
| 92 | - handler.StopBits = 1 |
| 93 | - handler.SlaveId = 11 |
| 94 | - handler.Logger = log.New(os.Stdout, "rtu: ", log.LstdFlags) |
| 95 | - err := handler.Connect() |
| 96 | - if err != nil { |
| 97 | - t.Fatal(err) |
| 98 | - } |
| 99 | - defer handler.Close() |
| 100 | - |
| 101 | - client := modbus.NewClient(handler) |
| 102 | - results, err := client.ReadDiscreteInputs(15, 2) |
| 103 | - if err != nil || results == nil { |
| 104 | - t.Fatal(err, results) |
| 105 | - } |
| 106 | - results, err = client.ReadWriteMultipleRegisters(0, 2, 2, 2, []byte{1, 2, 3, 4}) |
| 107 | - if err != nil || results == nil { |
| 108 | - t.Fatal(err, results) |
| 109 | - } |
| 110 | -} |
| 111 | Index: golang-github-goburrow-modbus/test/tcpclient_test.go |
| 112 | =================================================================== |
| 113 | --- golang-github-goburrow-modbus.orig/test/tcpclient_test.go 2020-12-08 19:39:28.377224009 +0000 |
| 114 | +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 |
| 115 | @@ -1,46 +0,0 @@ |
| 116 | -// Copyright 2014 Quoc-Viet Nguyen. All rights reserved. |
| 117 | -// This software may be modified and distributed under the terms |
| 118 | -// of the BSD license. See the LICENSE file for details. |
| 119 | - |
| 120 | -package test |
| 121 | - |
| 122 | -import ( |
| 123 | - "log" |
| 124 | - "os" |
| 125 | - "testing" |
| 126 | - "time" |
| 127 | - |
| 128 | - "github.com/goburrow/modbus" |
| 129 | -) |
| 130 | - |
| 131 | -const ( |
| 132 | - tcpDevice = "localhost:5020" |
| 133 | -) |
| 134 | - |
| 135 | -func TestTCPClient(t *testing.T) { |
| 136 | - client := modbus.TCPClient(tcpDevice) |
| 137 | - ClientTestAll(t, client) |
| 138 | -} |
| 139 | - |
| 140 | -func TestTCPClientAdvancedUsage(t *testing.T) { |
| 141 | - handler := modbus.NewTCPClientHandler(tcpDevice) |
| 142 | - handler.Timeout = 5 * time.Second |
| 143 | - handler.SlaveId = 1 |
| 144 | - handler.Logger = log.New(os.Stdout, "tcp: ", log.LstdFlags) |
| 145 | - handler.Connect() |
| 146 | - defer handler.Close() |
| 147 | - |
| 148 | - client := modbus.NewClient(handler) |
| 149 | - results, err := client.ReadDiscreteInputs(15, 2) |
| 150 | - if err != nil || results == nil { |
| 151 | - t.Fatal(err, results) |
| 152 | - } |
| 153 | - results, err = client.WriteMultipleRegisters(1, 2, []byte{0, 3, 0, 4}) |
| 154 | - if err != nil || results == nil { |
| 155 | - t.Fatal(err, results) |
| 156 | - } |
| 157 | - results, err = client.WriteMultipleCoils(5, 10, []byte{4, 3}) |
| 158 | - if err != nil || results == nil { |
| 159 | - t.Fatal(err, results) |
| 160 | - } |
| 161 | -} |