Skip to content

Commit 357383c

Browse files
committed
Exit codes 0 and 1.
1 parent 362631a commit 357383c

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

cmd/deviceparameter/deviceparameter.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import "github.com/thinnect/go-devparam"
1919

2020
const ApplicationVersionMajor = 0
2121
const ApplicationVersionMinor = 1
22-
const ApplicationVersionPatch = 2
22+
const ApplicationVersionPatch = 3
2323

2424
var ApplicationBuildDate string
2525
var ApplicationBuildDistro string
@@ -177,6 +177,8 @@ func main() {
177177
logger.Info.Printf("Connected to %s:%d\n", host, port)
178178
}
179179

180+
success := false
181+
180182
if len(opts.Parameter) > 0 {
181183
if len(opts.Value) == 0 || len(opts.Parameter) > 1 {
182184
for _, parameter := range opts.Parameter {
@@ -186,6 +188,7 @@ func main() {
186188
val, err := dpm.GetValue(parameter)
187189
if err == nil {
188190
logger.Info.Printf("%s = %s\n", val.Name, val)
191+
success = true
189192
} else {
190193
logger.Info.Printf("Failed: %s\n", err)
191194
}
@@ -196,6 +199,7 @@ func main() {
196199
logger.Info.Printf("Set %s to 0x%X\n", opts.Parameter[0], value)
197200
if val, err := dpm.SetValue(opts.Parameter[0], value); err == nil {
198201
logger.Info.Printf("%s = %s\n", val.Name, val)
202+
success = true
199203
} else {
200204
logger.Info.Printf("Failed: %s\n", err)
201205
}
@@ -215,6 +219,7 @@ func main() {
215219
logger.Info.Printf("%2d: %s\n", param.Seqnum, param.Error)
216220
}
217221
}
222+
success = true
218223
} else {
219224
logger.Info.Printf("Failed: %s\n", err)
220225
}
@@ -223,6 +228,12 @@ func main() {
223228
dpm.Close()
224229
sfc.Disconnect()
225230
time.Sleep(100 * time.Millisecond)
231+
232+
if success {
233+
os.Exit(0)
234+
} else {
235+
os.Exit(1)
236+
}
226237
}
227238

228239
func logsetup(debuglevel int) *loggers.DIWEloggers {

deviceparameters.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ func (self *DeviceParameterManager) waitValueId(name string) (*DeviceParameter,
227227
select {
228228
case packet := <-self.receive:
229229
payload := packet.GetPayload()
230+
231+
if self.destination != 0 {
232+
msg, ok := packet.(*sfconnection.Message)
233+
if !ok || msg.Source() != self.destination {
234+
self.Debug.Printf("Ignoring packet %s\n", packet)
235+
payload = nil
236+
}
237+
}
238+
230239
if len(payload) > 0 {
231240
if payload[0] == DP_PARAMETER {
232241
p := new(DpParameter)

0 commit comments

Comments
 (0)