forked from albenik/go-serial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
52 lines (43 loc) · 833 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Copyright 2019-2022 Veniamin Albaev <albenik@gmail.com>.
// All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
package serial
type Option func(p *Port)
func WithBaudrate(o int) Option {
return func(p *Port) {
p.baudRate = o
}
}
func WithDataBits(o int) Option {
return func(p *Port) {
p.dataBits = o
}
}
func WithParity(o Parity) Option {
return func(p *Port) {
p.parity = o
}
}
func WithStopBits(o StopBits) Option {
return func(p *Port) {
p.stopBits = o
}
}
func WithReadTimeout(o int) Option {
return func(p *Port) {
p.setReadTimeoutValues(o)
}
}
func WithWriteTimeout(o int) Option {
return func(p *Port) {
p.setWriteTimeoutValues(o)
}
}
func WithHUPCL(o bool) Option {
return func(p *Port) {
p.hupcl = o
}
}