blob: df089f20a22e92dfecb97ec5d5e31fc249aac09b (
plain)
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
|
package communication
import (
"log"
)
type SerialInterface struct {
phy physical
dl dataLink
}
func NewSerialInterface() (SerialInterface, error) {
iface := SerialInterface{}
var err error
iface.phy, err = newPhysical()
if err != nil {
return iface, err
}
iface.dl = newDataLink()
return iface, nil
}
func (i *SerialInterface) Start() {
i.phy.start()
i.dl.start(i.phy.rx)
}
func (i *SerialInterface) Cat() {
for {
data := <-i.dl.rx
log.Printf("RX: '%v'\n", data)
}
}
|