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) } }