-
Notifications
You must be signed in to change notification settings - Fork 0
/
serial.go
61 lines (46 loc) · 873 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
58
59
60
61
package ftdi
import (
"time"
"github.com/notifai/serial"
)
type serialPort struct {
dev *Device
}
var _ serial.Port = (*serialPort)(nil)
func (s *serialPort) Read(p []byte) (n int, err error) {
n, err = s.dev.Read(p)
return
}
func (s *serialPort) Write(p []byte) (n int, err error) {
n, err = s.dev.Write(p)
return
}
func (s *serialPort) Close() error {
return nil
}
func (s *serialPort) Flush() error {
return s.dev.PurgeBuffers()
}
func (s *serialPort) SetReadDeadline(time.Duration) error {
return nil
}
func (s *serialPort) Status() (uint, error) {
return 0, nil
}
func (s *serialPort) SetDTR(val bool) error {
vl := 0
if val {
vl = 1
}
return s.dev.SetDTR(vl)
}
func (s *serialPort) SetRTS(val bool) error {
vl := 0
if val {
vl = 1
}
return s.dev.SetRTS(vl)
}
func (s *serialPort) SetParity(_ serial.Parity) error {
return nil
}