-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial.go
57 lines (49 loc) · 991 Bytes
/
serial.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
53
54
55
56
57
// @@
// @ Author : Eacher
// @ Date : 2023-02-20 13:45:45
// @ LastEditTime : 2023-12-25 16:29:27
// @ LastEditors : Eacher
// @ --------------------------------------------------------------------------------<
// @ Description :
// @ --------------------------------------------------------------------------------<
// @ FilePath : /20yyq/serial/serial.go
// @@
package serial
import (
"time"
)
const (
SIZE0 = 0
SIZE5 = 5
SIZE6 = 6
SIZE7 = 7
SIZE8 = 8
STOP0 = 0
STOP1 = 1
STOP2 = 2
STOPHALF = 15
PARITY_ZERO = 0
PARITY_NONE = 'N'
PARITY_ODD = 'O'
PARITY_EVEN = 'E'
PARITY_MARK = 'M'
PARITY_SPACE = 'S'
)
// 串口开放的接口
type Serial interface {
Write([]byte) (int, error)
Read([]byte) (int, error)
InFlush() error
OutFlush() error
Close() error
SetConfig(Config) error
RestStart() error
}
type Config struct {
Baud uint32
Size byte
Parity byte
StopBits byte
MinByte uint8
ReadTime time.Duration
}